Example #1
0
        public static object ExecuteScalar(MySqlConnection conn, CommandType commandType, string commandText, params MySqlParameter[] parms)
        {
            MySqlCommand mySqlCommand = new MySqlCommand();

            MySqlHelper.PrepareCommand(conn, null, mySqlCommand, commandType, commandText, parms);
            object result = mySqlCommand.ExecuteScalar();

            mySqlCommand.Parameters.Clear();
            return(result);
        }
Example #2
0
        public static int ExecuteNonQuery(MySqlTransaction trans, CommandType commandType, string commandText, params MySqlParameter[] parms)
        {
            MySqlCommand mySqlCommand = new MySqlCommand();

            MySqlHelper.PrepareCommand(trans.Connection, trans, mySqlCommand, commandType, commandText, parms);
            int result = mySqlCommand.ExecuteNonQuery();

            mySqlCommand.Parameters.Clear();
            return(result);
        }
Example #3
0
        public static object ExecuteScalar(string connectionKeyOrConnectionString, string commandText, CommandType commandType, params MySqlParameter[] parms)
        {
            MySqlCommand mySqlCommand = new MySqlCommand();
            object       result;

            using (MySqlConnection mySqlConnection = new MySqlConnection(MySqlHelper.GetConnectionString(connectionKeyOrConnectionString)))
            {
                MySqlHelper.PrepareCommand(mySqlConnection, null, mySqlCommand, commandType, commandText, parms);
                object obj = mySqlCommand.ExecuteScalar();
                mySqlCommand.Parameters.Clear();
                result = obj;
            }
            return(result);
        }
Example #4
0
        public static int ExecuteNonQuery(string connectionKeyOrConnectionString, string commandText, CommandType commandType, params MySqlParameter[] parms)
        {
            MySqlCommand mySqlCommand = new MySqlCommand();
            int          result;

            using (MySqlConnection mySqlConnection = new MySqlConnection(MySqlHelper.GetConnectionString(connectionKeyOrConnectionString)))
            {
                MySqlHelper.PrepareCommand(mySqlConnection, null, mySqlCommand, commandType, commandText, parms);
                int num = mySqlCommand.ExecuteNonQuery();
                mySqlCommand.Parameters.Clear();
                result = num;
            }
            return(result);
        }
Example #5
0
        public static DataTable ExecuteDataTable(string connectionKeyOrConnectionString, string commandText, CommandType commandType, params MySqlParameter[] parms)
        {
            MySqlCommand mySqlCommand = new MySqlCommand();
            DataTable    result;

            using (MySqlConnection mySqlConnection = new MySqlConnection(MySqlHelper.GetConnectionString(connectionKeyOrConnectionString)))
            {
                MySqlHelper.PrepareCommand(mySqlConnection, null, mySqlCommand, commandType, commandText, parms);
                MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(mySqlCommand);
                DataTable        dataTable        = new DataTable();
                mySqlDataAdapter.Fill(dataTable);
                mySqlConnection.Close();
                mySqlCommand.Parameters.Clear();
                result = dataTable;
            }
            return(result);
        }
Example #6
0
        public static MySqlDataReader ExecuteReader(string connectionKeyOrConnectionString, string commandText, CommandType commandType, params MySqlParameter[] parms)
        {
            MySqlCommand    mySqlCommand    = new MySqlCommand();
            MySqlConnection mySqlConnection = new MySqlConnection(MySqlHelper.GetConnectionString(connectionKeyOrConnectionString));
            MySqlDataReader result;

            try
            {
                MySqlHelper.PrepareCommand(mySqlConnection, null, mySqlCommand, commandType, commandText, parms);
                MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
                mySqlCommand.Parameters.Clear();
                result = mySqlDataReader;
            }
            catch
            {
                mySqlConnection.Close();
                throw;
            }
            return(result);
        }