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); }
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); }
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); }
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); }