ASP.NET到MySQL的数据连接 [英] Asp.net to mySQL data connection

查看:53
本文介绍了ASP.NET到MySQL的数据连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,
这是我的Web配置文件


THIS IS MY web config file

<connectionstrings>
   
  <add name="connMySql" connectionstring="Driver={MySQL ODBC 3.51 Driver};server=kdemo.db.88443916.hostedresource.com;User Id=kdemo;database=kdemo;password=;Option=0;" />

    
  </connectionstrings>


这是代码文件


this is the code file

// Try to connect to the database based on our stored connection string.
string conString = WebConfigurationManager.ConnectionStrings["connMySql"].ConnectionString;
               using (OdbcConnection con = new OdbcConnection(conString))
               {
                   con.Open();
                   // We are now connected. Now we can use OdbcCommand objects
                   // to actually accomplish things.
               }


打开连接时会显示


when opening connection it is giving

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


任何帮助请


any help please

推荐答案

您需要检查web.config中的配置字符串-它与您所处的环境不匹配.

我们将无济于事:我们不知道您需要什么连接字符串-您也许可以通过在VS中设置数据连接并在属性窗格中查看该连接的ConectionString属性来获取它.
You need to check the configuration string in your web.config - it doesn''t match the environment you are in.

We can help no more: we have no idea what connection string your should need - you maybe able to get it by setting up a data connection in VS and looking at the ConectionString property for the connection in the properties pane.


Driver = {MySQL ODBC 3.51}根据安装更改驱动程序信息
并解决了问题.
Driver={MySQL ODBC 3.51} change driver information based on the installation
and the issue solved.


.net有一个MySql连接器.它会安装所需的驱动程序,以便可以通过ODBC使用mysql.所以

1.检查是否已在计算机中安装驱动程序.
2.如果是,则检查版本是否过时并导致问题.
There is a MySql connector for .net. waht it does it that it will install the required drivers so that the mysql can be used via ODBC. so

1. Check you have the drivers installed in machine.
2. If yes then check if the version is outdated and causing the problem.


这篇关于ASP.NET到MySQL的数据连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆