程序连接MySql数据库报错
开发Windows CE 5.0程序,要连接MySql数据库,总是报下面错误
错误1类型“System.Data.Common.DbConnection”在未被引用的程序集中定义。必须添加对程序集“System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。D:\dotNet\ETAM\src\MetoWarehouseMobileClient\MetoWarehouseMobileClient\LoginForm.cs22513MetoWarehouseMobileClient
在网上看到要引入一个MySql.Data.dll也已经引入了
private void connMySQLData() { // 查询语句 string sqlStr = "select * from storage"; // 连接属性 string connStr = "Server=192.168.1.112;User Id=root;Password=root;Persist Security Info=True;Database=storage"; MySqlConnection conn = new MySqlConnection(connStr); // 创建连接 conn.Open(); // 打开链接 MySqlCommand command = new MySqlCommand(sqlStr, conn); /*执行查询命令*/ MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Console.WriteLine(reader[0]); //reader.GetInt32(0); //reader.GetString(1); Console.WriteLine(reader[1]); Console.WriteLine(reader[2]); } conn.Close(); command = null; reader.Close(); }