本文整理匯總了C#中MySql.Data.MySqlClient.MySqlConnection.CheckAndOpen方法的典型用法代碼示例。如果您正苦於以下問題:C# MySqlConnection.CheckAndOpen方法的具體用法?C# MySqlConnection.CheckAndOpen怎麽用?C# MySqlConnection.CheckAndOpen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MySql.Data.MySqlClient.MySqlConnection
的用法示例。
在下文中一共展示了MySqlConnection.CheckAndOpen方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ExecuteDatarow
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: UpdateDataSet
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: GetConnection_Writable
public static MySqlConnection GetConnection_Writable()
{
var conn = new MySqlConnection {ConnectionString = ConnectionString_Writable};
conn.CheckAndOpen();
return conn;
}
示例4: GetConnection_ReadOnly
public static MySqlConnection GetConnection_ReadOnly()
{
var conn = new MySqlConnection {ConnectionString = ConnectionString_ReadOnly};
conn.CheckAndOpen();
return conn;
}
示例5: ExecuteScalar
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: ExecuteReader
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: ExecuteNonQueryAndCloseConnection
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);
}
}