예제 #1
0
        public static DataRow ExecuteDatarow(string connectionString, string commandText, params MySqlParameter[] parms)
        {
            DataRow row = null;
            using (var cn = new MySqlConnection(connectionString))
            {
                cn.CheckAndOpen();

                //call the overload that takes a connection in place of the connection string
                row = ExecuteDatarow(cn, null, commandText, parms);
            }
            return row;
        }
예제 #2
0
 public static void UpdateDataSet(string connectionString, string commandText, DataSet ds, string tablename)
 {
     var cn = new MySqlConnection(connectionString);
     cn.CheckAndOpen();
     var da = new MySqlDataAdapter(commandText, cn);
     var cb = new MySqlCommandBuilder(da);
     da.Update(ds, tablename);
     cn.Close();
 }
예제 #3
0
 public static MySqlConnection GetConnection_Writable()
 {
     var conn = new MySqlConnection {ConnectionString = ConnectionString_Writable};
     conn.CheckAndOpen();
     return conn;
 }
예제 #4
0
 public static MySqlConnection GetConnection_ReadOnly()
 {
     var conn = new MySqlConnection {ConnectionString = ConnectionString_ReadOnly};
     conn.CheckAndOpen();
     return conn;
 }
예제 #5
0
        public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
        {
            //create & open a SqlConnection, and dispose of it after we are done.
            using (var cn = new MySqlConnection(connectionString))
            {
                cn.CheckAndOpen();

                //call the overload that takes a connection in place of the connection string
                return ExecuteScalarWithOpenConnection(cn, null, commandText, commandParameters);
            }
        }
예제 #6
0
        public static MySqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText, params MySqlParameter[] commandParameters)
        {
            //create & open a SqlConnection
            var cn = new MySqlConnection(connectionString);
            cn.CheckAndOpen();

            try
            {
                //call the private overload that takes an internally owned connection in place of the connection string
                return ExecuteReader(cn, null, commandText, commandType, commandParameters, false);
            }
            catch
            {
                //if we fail to return the SqlDatReader, we need to close the connection ourselves
                cn.Close();
                throw;
            }
        }
예제 #7
0
        public static int ExecuteNonQueryAndCloseConnection(string connectionString, string commandText, params MySqlParameter[] parms)
        {
            //create & open a SqlConnection, and dispose of it after we are done.
            using (var cn = new MySqlConnection(connectionString))
            {
                cn.CheckAndOpen();

                //call the overload that takes a connection in place of the connection string
                return ExecuteNonQueryAndKeepConnection(cn, commandText, parms);
            }
        }