C# 为什么我不能使用驱动程序连接字符串连接到MySql.Net,因为它与Delphi';那是塔多克利?
我有这样的连接字符串:C# 为什么我不能使用驱动程序连接字符串连接到MySql.Net,因为它与Delphi';那是塔多克利?,c#,mysql,.net,database-connection,ado,C#,Mysql,.net,Database Connection,Ado,我有这样的连接字符串: Driver={MySQL ODBC 8.0 Unicode Driver}; Server=localhost; Database=data; UID=root; Password=admin; 我用Delphi编写的程序连接正确。但是相同的连接字符串在C#.net标准System.Data.SqlClient.SqlConnection对象中不起作用 错误是: System.ArgumentException: Keyword not supported: 'dri
Driver={MySQL ODBC 8.0 Unicode Driver}; Server=localhost; Database=data; UID=root; Password=admin;
我用Delphi编写的程序连接正确。但是相同的连接字符串在C#.net标准System.Data.SqlClient.SqlConnection对象中不起作用
错误是:
System.ArgumentException: Keyword not supported: 'driver'. at
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)
因为.Net不是Delphi。有关连接字符串,请参见:您需要对该连接字符串使用
OdbcConnection
而不是SqlConnection
。但是如果您是从.NET连接到MySQL,我强烈建议不要使用ODBC驱动程序,而是使用;它更现代。