当前位置: 代码迷 >> WinCE >> 程序联接MySql数据库报错
  详细解决方案

程序联接MySql数据库报错

热度:53   发布时间:2016-04-28 12:52:29.0
程序连接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.cs 225 13 MetoWarehouseMobileClient


在网上看到要引入一个MySql.Data.dll也已经引入了


C# code
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();        }


------解决方案--------------------
是否还要添加lib文件……
  相关解决方案