运行.net网站而不在系统上安装MySQL ODBC 5.1驱动程序

时间:2013-06-24 07:41:19

标签: asp.net mysql asp.net-mvc odbc

我想运行我的.net网站而不在系统上安装MySQL ODBC 5.1驱动程序。我在bin文件夹中添加了myodbc5 dll,但在打开连接时会抛出异常。例外情况如下:

"ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

我的连接字符串如下:

<connectionStrings><add name="ConnectionString" connectionString="Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=demo;PORT=3306;Uid=root;Pwd=1234;OPTION=3;"/></connectionStrings>

我试图在连接字符串中添加providerName =“System.Data.Odbc”,但它没有用。我使用的是MySQL 5.6.11版本。 我想运行代码而不在我的系统上安装ODBC驱动程序,但只包括dll的odbc驱动程序。

请帮忙。 提前致谢

1 个答案:

答案 0 :(得分:0)

这是我使用的MySQL Connector / NET DLL。只需添加对MySql.Data的引用。

<connectionStrings>
<add name="MySqlConnectionString" connectionString="server=MyServer;User Id=yourusername;password=yourpassword;Persist Security Info=True;database=yourdatabase" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>