Hi, I'm trying to connect to my mySQL server through asp.net, but no matter what I do, I keep getting the same error: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified I've tried installing everything
over and over again, and I've used alle kinds of tutorials. But nothing is working. Here's the code I using on my page: <script language="C#" runat="server"> protected void Page_Load(Object sender, EventArgs e) { string mySQLConnStr = "driver={MySQL};"; mySQLConnStr
= mySQLConnStr + "server=localhost;"; mySQLConnStr = mySQLConnStr + "uid=root;"; mySQLConnStr = mySQLConnStr + "pwd=;"; mySQLConnStr = mySQLConnStr + "database=mysql;"; mySQLConnStr = mySQLConnStr + "OPTION=17923"; OdbcConnection myConnection = new OdbcConnection
(mySQLConnStr); string SQL = "select * from user"; OdbcDataAdapter myCommand = new OdbcDataAdapter(SQL, myConnection); DataSet ds = new DataSet(); myCommand.Fill(ds, "user"); MyDataGrid.DataSource=ds.Tables["user"].DefaultView; MyDataGrid.DataBind(); } </script>
MAKE ABSOLUTELY CERTAIN your "Driver={}" string is CORRECT. To check go to: Control Panel > Admin Tools > Data Sources (ODBC) > [Tab] Drivers Scroll down until you see the MySQL driver, and see what the NAME is. Use that EXACT name in your string. If you can't
find it, your page won't work, you need to install the MyODBC drivers...if you're using MyODBC 3.51 your string should look like:
DRIVER={MySQL ODBC 3.51 Driver}
If it's localhost, don't bother adding the "server=" attribute...it automatically assumes that. And what is the "option"
for? Don't use it unless you need it :) Hope that helped.
Another option is to get the CoreLab.MySql.dll from Core Labs ... 1. Install the driver 2. Add it to Web Matrix 3. Create a "bin" directory in you web folder 4. VOILA!
i am having trouble getting the system.data.odbc namespace. any idea why? i am able to connect to MySQL via ASP and now i am trying to access the database via ASP.NET. i've tried downloading and installing the MDAC but to no avail. appreciate any kind of help.
thank you in advance. shaheed
Hi Shaheed, The ODBC provider is not part of MDAC, which is COM-based ADO. You can get the provider
here. Don
Don Kiely, MCP, MCSD
In the Last Frontier, Interior Alaska
Please post questions and replies to the forum! And remember to MARK AS ANSWER when someone definitively answers a question or resolves a problem!
Okay, how do you know you're not getting the namespace? What development tools are you using? What code are you trying to write? Don
Don Kiely, MCP, MCSD
In the Last Frontier, Interior Alaska
Please post questions and replies to the forum! And remember to MARK AS ANSWER when someone definitively answers a question or resolves a problem!
You need to reference the Microsoft.ODBC.Data namespace just like the other namespace references. Even if the DLL's have been added to the gac, you have to do this reference. I keep forgetting myself.
zoulman
Member
60 Points
12 Posts
MySQL :o(
May 31, 2003 03:28 PM|LINK
Please Help Me!!
SubKamran
Member
94 Points
20 Posts
Re: MySQL :o(
Jun 01, 2003 02:40 PM|LINK
DRIVER={MySQL ODBC 3.51 Driver}If it's localhost, don't bother adding the "server=" attribute...it automatically assumes that. And what is the "option" for? Don't use it unless you need it :) Hope that helped.Web Developer
ASP / .NET / JavaScript / CSS / XHTML
zoulman
Member
60 Points
12 Posts
Re: MySQL :o(
Jun 02, 2003 12:04 PM|LINK
Bandito412
Member
50 Points
10 Posts
Re: MySQL :o(
Jun 30, 2003 07:00 PM|LINK
shaheedborha...
Member
5 Points
1 Post
Re: MySQL :o(
Aug 07, 2003 04:45 PM|LINK
donkiely
All-Star
15929 Points
2518 Posts
ASPInsiders
Moderator
MVP
Re: MySQL :o(
Aug 07, 2003 05:48 PM|LINK
In the Last Frontier, Interior Alaska
Please post questions and replies to the forum! And remember to MARK AS ANSWER when someone definitively answers a question or resolves a problem!
masterduc
Member
10 Points
2 Posts
Re: MySQL :o(
Aug 11, 2003 03:43 AM|LINK
donkiely
All-Star
15929 Points
2518 Posts
ASPInsiders
Moderator
MVP
Re: MySQL :o(
Aug 11, 2003 04:57 AM|LINK
In the Last Frontier, Interior Alaska
Please post questions and replies to the forum! And remember to MARK AS ANSWER when someone definitively answers a question or resolves a problem!
flycast@bell...
Member
40 Points
8 Posts
Re: MySQL :o(
Aug 12, 2003 12:28 PM|LINK
masterduc
Member
10 Points
2 Posts
Re: MySQL :o(
Aug 18, 2003 02:50 AM|LINK