.NET 使用 mysql.Data.dll 动态库操作MySql的帮助类–MySqlHelper
.NET 使用 MySql.Data.dll 动态库操作MySql的帮助类–MySqlHelper
参考示例代码,如下所示:
/// /// MySql 数据库操作类 /// public class MySqlHelper { #region MysqlConnection private static MySql.Data.MySqlClient.MySqlConnection _mysqlConnection; /// /// MySqlConnection 连接信息 /// public static MySql.Data.MySqlClient.MySqlConnection MysqlConnection { get { String mysqlConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[“Libor_MySql_QuoteCenter_ConnectionString”].ToString(); if (_mysqlConnection == null) _mysqlConnection = new MySql.Data.MySqlClient.MySqlConnection(mysqlConnectionString); if (_mysqlConnection.State == System.Data.ConnectionState.Closed) _mysqlConnection.Open(); if (_mysqlConnection.State == System.Data.ConnectionState.Broken) { _mysqlConnection.Close(); _mysqlConnection.Open(); } return MySqlHelper._mysqlConnection;