Beispiel #1
0
        public static SqlConnection GetSqlConnection()
        {
            SqlConnection con = null;

            try
            {
                con = DBAccessController.dbGetSqlConnection();
            }
            catch (Exception ex)
            {
                WriteLog(ex, "GetSqlConnection()", true, true);
            }
            return(con);
        }
        public static async Task <bool> OracleCommandExecute(byte[] dataDecrypted, string action)
        {
            bool result = false;

            try
            {
                string        oracleCommandString = Encoding.UTF8.GetString(dataDecrypted);
                OracleCommand cmd         = new OracleCommand(oracleCommandString, DBAccessController.dbGetOracleConnection());
                int           afectedRows = cmd.ExecuteNonQuery();
                if (afectedRows > 0)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Sistem.WriteLog(ex, "OracleCommandExecute(byte[] dataDecrypted, string action)", true);
            }
            return(result);
        }
        /// <summary>
        /// EXEC NON QUERY COMMANDS WITH NO RETURN OF DATA
        /// </summary>
        /// <param name="dataDecrypted"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static async Task <bool> SqlCommandExecute(byte[] dataDecrypted, string action)
        {
            bool result = false;

            try
            {
                //INSERT, UPDATE AND DELETE
                string     sqlCommandString = Encoding.UTF8.GetString(dataDecrypted);
                SqlCommand cmd         = new SqlCommand(sqlCommandString, DBAccessController.dbGetSqlConnection());
                int        afectedRows = cmd.ExecuteNonQuery();
                if (afectedRows > 0)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Sistem.WriteLog(ex, "SqlCommandExecute(byte[] dataDecrypted, string action)", true);
            }
            return(result);
        }
        /// <summary>
        /// EXEC QUERY COMMANDS THAT RETURNS DATA
        /// </summary>
        /// <param name="dataDecrypted"></param>
        /// <param name="action"></param>
        /// <param name="returnDt"></param>
        /// <returns></returns>
        public static async Task <DataTable> SqlCommandExecute(byte[] dataDecrypted, string action, bool returnDt = true)
        {
            DataTable result = null;

            try
            {
                string         sqlCommandString = Encoding.UTF8.GetString(dataDecrypted);
                SqlCommand     cmd = new SqlCommand(Encoding.UTF8.GetString(dataDecrypted), DBAccessController.dbGetSqlConnection());
                SqlDataAdapter da  = new SqlDataAdapter(cmd);
                da.Fill(result);
            }
            catch (Exception ex)
            {
                Sistem.WriteLog(ex, "SqlCommandExecute(byte[] dataDecrypted, string action, bool returnDt = true)", true);
            }
            return(result);
        }