Esempio n. 1
0
        async Task <dynamic> execute(DbCmdType type = DbCmdType.NonQuery)
        {
            switch (connType)
            {
            case DbConType.MsSQL:
                switch (type)
                {
                case DbCmdType.NonQuery:
                    return(await msSQL_cmd.ExecuteNonQueryAsync().ConfigureAwait(true));

                case DbCmdType.Scalar:
                    return(await msSQL_cmd.ExecuteScalarAsync().ConfigureAwait(true));

                case DbCmdType.Reader:
                    return(await msSQL_cmd.ExecuteReaderAsync().ConfigureAwait(true));
                }
                break;

            case DbConType.MySQL:
                switch (type)
                {
                case DbCmdType.NonQuery:
                    return(await mySQL_cmd.ExecuteNonQueryAsync().ConfigureAwait(true));

                case DbCmdType.Scalar:
                    return(await mySQL_cmd.ExecuteScalarAsync().ConfigureAwait(true));

                case DbCmdType.Reader:
                    return(await mySQL_cmd.ExecuteReaderAsync().ConfigureAwait(true));
                }
                break;
            }

            return(null);
        }
Esempio n. 2
0
        public async Task <dynamic> Execute(DbCmdType type = DbCmdType.NonQuery)
        {
            try
            {
                return(await execute(type));
            }
            catch (Exception ex)
            {
                OnError(new DBError($"An Exception has occured!\nMessage: {ex.Message}\nStack-Trace: {ex.StackTrace}"));
            }

            return(null);
        }
Esempio n. 3
0
        public async Task <dynamic> Execute(DbCommand cmd, DbCmdType type = DbCmdType.NonQuery)
        {
            try
            {
                SetCommand(cmd);
                return(await execute(type));
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An Exception has occured!\nMessage: {ex.Message}\nStack-Trace: {ex.StackTrace}", "execute", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
            }

            return(null);
        }
Esempio n. 4
0
        public async Task <dynamic> Execute(string text, DbParameter parameters, DbCmdType type = DbCmdType.NonQuery, bool keepAlive = false)
        {
            try
            {
                NewCommand(text);
                return(await execute(type));
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An Exception has occured!\nMessage: {ex.Message}\nStack-Trace: {ex.StackTrace}", "Execute", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
            }

            return(null);
        }