首先呢,去Mysql官网下载MySql.Data.dll,然后添加引用
using MySql.Data.MySqlClient;
然后使用连接字符串的时候,使用以下代码:
MySqlConnectionStringBuilder s = new MySqlConnectionStringBuilder();
s.Server = "192.168.0.100";
s.Port = 3306; //mysql端口号
s.Database = "dbName";
s.UserID = "root";
s.Password = "root";
s.CharacterSet = "latin1";
MySqlConnection mcon = new MySqlConnection(s.ConnectionString);
其他的档宏也要用mysql的,比如燃猛MySqlCommand等等。有疑问行段册可以追问~
连接字符串没问题
不过连接mysql需要银激搭用mysql的.net connector
到 http://www.mysql.com/products/connector/ 下载ADO.NET Driver for MySQL (Connector/NET)
代码中
using MySql.Data.MySqlClient;
用锋拿铅念MysqlConnection 不要用sqlconnection