2016-09-30 107 views
-1


Xamarin无法连接到MySQL

db是我的MySqlConnection。当我试图运行:db.Open();我得到这个错误:

The type 'System.Data.Common.DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”.

所以我跟着它,并添加System.Data参考。现在,我得到这个错误:

Reference to type 'Component' claims it is defined in System but it could not be found

我使用的.NET Framework 4.0版中,MySQL连接器v6.9.9,Xamarin窗体v2.3.2.127和所有支持Android v23.4.0.1

附:我读了一些关于PCL的内容,但我不知道我使用的包是PCL。

+0

共享连接字符串。 – Anjali

+0

'db = new MySqlConnection(“Server = 192.168.56.2; port = 3306; User Id = user; Password = aa”);'' – Triti

回答

0

请连接字符串指定数据库名称

Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername; 
Pwd=myPassword 
0

也许这不是一个很好的解决方案,但我感动整个代码复制到特定的Android项目,它完美的作品。