Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不支持MySQL关键字:';端口';C#应用程序中的错误_Mysql_Mysql Error 1064 - Fatal编程技术网

不支持MySQL关键字:';端口';C#应用程序中的错误

不支持MySQL关键字:';端口';C#应用程序中的错误,mysql,mysql-error-1064,Mysql,Mysql Error 1064,我正在尝试连接到我的c#.Net应用程序中的MySQL数据库 尝试连接时出现此错误:关键字不受支持:“端口” 该错误似乎表明我的连接字符串有问题 <add name="mydataEntities" connectionString="server=myserver.com;port=3306;password=xxxx;user id=yyyy;database= mydatabase;persistsecurityinfo=True" providerName="MySql.Data.

我正在尝试连接到我的c#.Net应用程序中的MySQL数据库

尝试连接时出现此错误:关键字不受支持:“端口”

该错误似乎表明我的连接字符串有问题

<add name="mydataEntities" connectionString="server=myserver.com;port=3306;password=xxxx;user id=yyyy;database= mydatabase;persistsecurityinfo=True" providerName="MySql.Data.MySqlClient" />
我注意到堆栈跟踪似乎正在使用System.Data.SqlClient提供程序,如下所示:

我已经删除了MySql.Data和MySql.Data.Entity.EF6引用,清理解决方案,添加回引用,然后重建

有人能帮我找出这个错误的来源吗

为什么MySQL连接器没有使用我的配置中指定的providerName:MySQL.Data.MySqlClient

   at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
   at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
   at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
   at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
   at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
   at System.Data.SqlClient.SqlConnection..ctor(String connectionString, SqlCredential credential)
   at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
   at System.Data.Entity.Infrastructure.SqlConnectionFactory.CreateConnection(String nameOrConnectionString)
   at System.Data.Entity.Infrastructure.LocalDbConnectionFactory.CreateConnection(String nameOrConnectionString)
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName()
   at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
位于System.Data.Common.DbConnectionOptions.ParseInternal(哈希表parsetable、字符串connectionString、布尔构建链、哈希表同义词、布尔第一键)
位于System.Data.Common.DbConnectionOptions..ctor(字符串连接字符串、哈希表同义词、布尔useOdbcRules)
位于System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
位于System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString,DbConnectionOptions previous)
位于System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey、DbConnectionPoolGroupOptions、DbConnectionOptions和userConnectionOptions)
位于System.Data.SqlClient.SqlConnection.ConnectionString_集合(DbConnectionPoolKey)
位于System.Data.SqlClient.SqlConnection.set_ConnectionString(字符串值)
位于System.Data.SqlClient.SqlConnection..ctor(字符串连接字符串,SqlCredential凭据)
位于System.Data.SqlClient.SqlConnection..ctor(字符串连接字符串)
位于System.Data.Entity.Infrastructure.SqlConnectionFactory.CreateConnection(字符串名称或连接字符串)
位于System.Data.Entity.Infrastructure.LocalDbConnectionFactory.CreateConnection(字符串名称或连接字符串)
在System.Data.Entity.Internal.LazyInternalConnection.Initialize()中
在System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()中
在System.Data.Entity.Internal.LazyInternalContext.get_ProviderName()中
位于System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext上下文)
在System.Data.Entity.Internal.LazyInternalContext.InitializeContext()中
位于System.Data.Entity.Internal.InternalContext.Initialize()处
位于System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型entityType)
位于System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
位于System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()处
位于System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
在System.Linq.Enumerable.WhereSelectEnumerableInterator`2.MoveNext()中
位于System.Collections.Generic.List`1..ctor(IEnumerable`1集合)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
以下是解决方案:

我从一个部分类中删除了以下代码,该部分类重写了基类中的连接字符串

public partial class mydataEntities
    {
        public mydataEntities(string connectionString) : base(connectionString) { }
    }

我仍然对该解决方案感到困惑,但似乎使用此代码连接试图使用Mssql数据提供程序而不是MySql

有人能帮我找出此错误的来源吗?在哪里指定
mydataEntities
作为要在C#code中使用的连接字符串?我更新了票证,以显示我在哪里指定了要使用的连接字符串。我遇到了一个类似的问题,即
port
关键字。我也遇到了同样的问题,比如
allowuservariables
关键字。不过,您不需要使用
端口
关键字,因为默认端口是3306,看起来您正试图连接到它。奇怪的是,我有另一个应用程序使用关键字port,它可以工作。我从连接字符串中删除了“port”。现在出现此错误:在建立到SQL Server的连接时发生了与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:命名管道提供程序,错误:40-无法打开到SQL Server的连接):无法找出我的应用程序仍在使用的原因:.Net SqlClient数据提供程序-我已删除所有引用
   at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
   at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
   at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
   at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
   at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
   at System.Data.SqlClient.SqlConnection..ctor(String connectionString, SqlCredential credential)
   at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
   at System.Data.Entity.Infrastructure.SqlConnectionFactory.CreateConnection(String nameOrConnectionString)
   at System.Data.Entity.Infrastructure.LocalDbConnectionFactory.CreateConnection(String nameOrConnectionString)
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName()
   at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
public partial class mydataEntities
    {
        public mydataEntities(string connectionString) : base(connectionString) { }
    }