使用ODBC通过ASP.NET连接到MySql [英] Connecting to MySql through ASP.NET using ODBC
问题描述
嗨朋友们。
请帮我解决这个问题。
我正在尝试使用ASP.Net连接到MySql。
我正在使用此代码执行此操作:
使用System.Data;
使用System。 Data.Odbc;
$
// ......
$
DataSet Mysql_ds = new DataSet();
$
OdbcConnection Mysql_con;
字符串Mysql_conStr =" Driver = {MySQL ODBC 4.1 Driver}; Server = SERVERNAME; Database = DBNAME; uid = USER; pwd = PASS" ;;
Mysql_con = new OdbcConnection(Mysql_conStr);
Mysql_con.Open();
//....
当我在C#,WindowsFrom应用程序中使用它时,此代码运行良好但是当我在ASP.NET中使用此代码并将其上传到我的服务器,当我转到我的网站地址时,我收到此错误:
< b>异常详细信息:< / b> System.Data.Odbc.OdbcException:ERROR [IM002] [Microsoft] [ODBC驱动程序管理器]未找到数据源名称且未指定默认驱动程序
错误行是在最后一行(Mysql_con.open())。
$
我搜索了很多并做了一些尝试但没有解决:(
我应该如何解决这个问题!
$
或
有没有更好的方法来创建mysql连接!?$
这里是关于服务器站点上安装的MySql的一些信息:
localhost:
服务器版本:4.1.22-community-nt
协议版本:10
服务器:localhost通过TCP / IP
用户:USER@127.0.0.1
phpMyAdmin - 2.10.1:
$
MySQL客户端版本:5.0.45
使用的PHP扩展:mysql
我通常使用
.NET连接器,即i我认为这是一个不错的选择。您是否尝试过没有驱动程序规范的连接字符串?使用.NET连接器,我的连接字符串类似于以下内容:server = YourServer; User Id = TheUser; PWD = ThePassword;数据库= YourDatabase
Hi friends.
help me with this issue please.
I'm trying to connect to MySql using ASP.Net.
i'm using this code to do this:
using System.Data;
using System.Data.Odbc;
//......
DataSet Mysql_ds = new DataSet();
OdbcConnection Mysql_con;
string Mysql_conStr = "Driver={MySQL ODBC 4.1 Driver};Server=SERVERNAME;Database=DBNAME;uid=USER;pwd=PASS";
Mysql_con = new OdbcConnection(Mysql_conStr);
Mysql_con.Open();
//....
this code works well when i use it in C#, WindowsFrom Application, BUT When I use this code in ASP.NET and upload it to my server, when i go to my website address, i get this error :
<b>Exception Details:</b> System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
the error line is in the last line ( Mysql_con.open() ).
I have searched a lot and do some tries but nothing solved :(
How should I solve this problem!
OR
Is there any better way to create mysql connection !?
here is some information about the MySql installed on the server site :
localhost:
Server version: 4.1.22-community-nt
Protocol version: 10
Server: localhost via TCP/IP
User: USER@127.0.0.1
phpMyAdmin - 2.10.1:
MySQL client version: 5.0.45
Used PHP extensions: mysql
Hi,
I normally work with the .NET connector, which is in my opinion a good choice. Have you tried the connection string without the driver specification? With the .NET connector my connection string looks similar to the following:
server=YourServer;User Id=TheUser; Pwd=ThePassword; database=YourDatabase
这篇关于使用ODBC通过ASP.NET连接到MySql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!