Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.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
C# 为什么我不能使用驱动程序连接字符串连接到MySql.Net,因为它与Delphi';那是塔多克利?_C#_Mysql_.net_Database Connection_Ado - Fatal编程技术网

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驱动程序,而是使用;它更现代。