mysql官方网站说得很清楚: Connector/Net is a fully-managed ADO.NET driver for MySQL. Starting with version 6.7, Connector/Net will no longer include the MySQL for Visual Studio integration. That functionality is now available in a separate product called MySQL for Visual Studio available using the MySQL Installer for Windows (see http://dev.mysql.com/tech-resources/articles/mysql-installer-for-windows.html).使用Connector/Net 6.6.6版本测试通过!或根据官网说明,下载mysql-connector-net-6.8.3-noinstall.zip。 Select Platform… .NET & Mono 再下载。
public string jk430_chehao(string chexing) { string MySqlConnection = ConfigurationManager.AppSettings["jk430DBConnectionString"]; MySqlConnection mConnection = new MySqlConnection(MySqlConnection); mConnection.Open(); sql = "select TrainCode from datainfo where TrainType='" + chexing + "' group by TrainCode"; MySqlDataAdapter SqlAda = new MySqlDataAdapter(sql, mConnection); SqlAda.SelectCommand = new MySqlCommand(); SqlAda.SelectCommand.Connection = mConnection; SqlAda.SelectCommand.CommandText = sql; SqlAda.Fill(ds, "Dzb_jk430"); Dt = ds.Tables[0]; mConnection.Close(); return db.DataTable2Json(Dt, 10); }jk430DBConnectionString是webConfig中配置的连接字符串
Connector/Net is a fully-managed ADO.NET driver for MySQL.
Starting with version 6.7, Connector/Net will no longer include the MySQL for Visual Studio integration. That functionality is now available in a separate product called MySQL for Visual Studio available using the MySQL Installer for Windows (see http://dev.mysql.com/tech-resources/articles/mysql-installer-for-windows.html).使用Connector/Net 6.6.6版本测试通过!或根据官网说明,下载mysql-connector-net-6.8.3-noinstall.zip。
Select Platform… .NET & Mono 再下载。
string MySqlConnection = ConfigurationManager.AppSettings["jk430DBConnectionString"];
MySqlConnection mConnection = new MySqlConnection(MySqlConnection);
mConnection.Open();
sql = "select TrainCode from datainfo where TrainType='" + chexing + "' group by TrainCode";
MySqlDataAdapter SqlAda = new MySqlDataAdapter(sql, mConnection);
SqlAda.SelectCommand = new MySqlCommand();
SqlAda.SelectCommand.Connection = mConnection;
SqlAda.SelectCommand.CommandText = sql;
SqlAda.Fill(ds, "Dzb_jk430");
Dt = ds.Tables[0];
mConnection.Close();
return db.DataTable2Json(Dt, 10);
}jk430DBConnectionString是webConfig中配置的连接字符串
2.引用组件MySQL.Data.dll
3.然后MySqlConnection,MySqlConnectionString。。这些看行去都眼熟吧。:)