c# - Xamarin无法连接到mysql

标签 c# mysql .net xamarin xamarin.android


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 v4.0、MySQL Connector v6.9.9、Xamarin Forms v2.3.2.127 和所有 Android 支持 v23.4.0.1

附注我读过一些有关 PCL 的内容,但我不知道我使用的包是否是 PCL。

最佳答案

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

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

关于c# - Xamarin无法连接到mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39789051/

相关文章:

MySQL - 将 "hh:mm PM"转换为 unix 时间戳

.net - List(Of T) 被未知英雄救了?

c# - 使用 SQLite 对 NHibernate Postgresql 进行单元测试。序列发生器问题

mysql - 使用flask-migrate时出现Flask迁移错误

mysql - 我们如何知道某个 View 是否已被使用

c# - System32 文件夹的 Environment.GetFolderPath(Environment.SpecialFolder.System) 和 Environment.SystemDirectory 之间的区别

c# - 使用 System.Net.Mail.MaiMessage 使用 C# 发送时如何防止 HTML 电子邮件引用可打印

c# - 无法转换类型为 'System.Collections.Generic.List` 的对象 1[System.Decimal ]' to type ' System.IConvertible'

c# - 检查当前是否显示了 ContentPage

c# - Entity Framework 核心 1.0.0 : Eager loading with Where-clause