当前位置: 首页>>代码示例>>C#>>正文


C# MySqlConnection.CheckAndOpen方法代码示例

本文整理汇总了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;
        }
开发者ID:ullassagar,项目名称:eshop,代码行数:12,代码来源:MysqlRepository.cs

示例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();
 }
开发者ID:ullassagar,项目名称:eshop,代码行数:9,代码来源:MysqlRepository.cs

示例3: GetConnection_Writable

 public static MySqlConnection GetConnection_Writable()
 {
     var conn = new MySqlConnection {ConnectionString = ConnectionString_Writable};
     conn.CheckAndOpen();
     return conn;
 }
开发者ID:ullassagar,项目名称:eshop,代码行数:6,代码来源:MysqlRepository.cs

示例4: GetConnection_ReadOnly

 public static MySqlConnection GetConnection_ReadOnly()
 {
     var conn = new MySqlConnection {ConnectionString = ConnectionString_ReadOnly};
     conn.CheckAndOpen();
     return conn;
 }
开发者ID:ullassagar,项目名称:eshop,代码行数:6,代码来源:MysqlRepository.cs

示例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);
            }
        }
开发者ID:ullassagar,项目名称:eshop,代码行数:11,代码来源:MysqlRepository.cs

示例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;
            }
        }
开发者ID:ullassagar,项目名称:eshop,代码行数:18,代码来源:MysqlRepository.cs

示例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);
            }
        }
开发者ID:ullassagar,项目名称:eshop,代码行数:11,代码来源:MysqlRepository.cs


注:本文中的MySql.Data.MySqlClient.MySqlConnection.CheckAndOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。