MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 25th, 2003, 02:22 PM
waveout waveout is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Georgia
Posts: 2 waveout User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy unable to connect to mysql database using asp

I'm using Windows XP Pro and I'm trying to connect to a MySQL Database using the following asp code:

<%@ Language=VBScript %>
<%
Dim my_conn, strSQL, rs

Set my_conn = createobject("ADODB.Connection")

my_conn.open = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& "DATABASE=test;"_
& "UID=root;"_
& "PWD=;"

strSQL = "SELECT * FROM names"

Set rs = conn.Execute(strSQL)

Do while not rs.eof ' Do until it reaches end of db

Response.Write "User ID# " & rs("ID") & "<br>"
Response.Write "FirstName: " & rs("FirstName") & "<br>"
Response.Write "LastName: " & rs("LastName") & "<br>"

rs.MoveNext 'Next record
loop

my_conn.close ' Close database connection
Set my_conn = nothing 'obj variable released

%>

I'm getting the following error in Explorer:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'localhost' (10022)
/test99.asp, line 10

I'm able to connect to the database using mysql -u root -h localhost (i have not setup any passwords yet) and I'm also able to connect to the database from Borland C++ Builder. But I'm not able to connect using the above code and I can not figure out what is going on. Could someone please look it over and let me know if they see the problem.

Thanks,
Dave

Reply With Quote
  #2  
Old November 25th, 2003, 04:26 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Do a search in this forum. I believe this question has been answered several times.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old November 26th, 2003, 07:29 PM
waveout waveout is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Georgia
Posts: 2 waveout User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy

Believe me I searched this forum and every other forum I could find on the net that discusses mysql and asp. I even setup a dsn connection and tried it that way. It still will not work. When I setup the dsn I clicked the test connection button and it connected with no problem. I'm using mysql 4.0.16-max-net, Windows XP and IIS. Here's my code using the dsn connection:


<%@ Language=VBScript %>
<%
Dim my_conn, strSQL, rs

Set my_conn = createobject("ADODB.Connection")

// I setup the mysql_dsn under the system DSN tab
my_conn.open = "DSN=mysql_dsn;"

strSQL = "SELECT * FROM names"

Set rs = conn.Execute(strSQL)

Do while not rs.eof ' Do until it reaches end of db

Response.Write "User ID# " & rs("ID") & "<br>"
Response.Write "FirstName: " & rs("FirstName") & "<br>"
Response.Write "LastName: " & rs("LastName") & "<br>"

rs.MoveNext 'Next record
loop

my_conn.close ' Close database connection
Set my_conn = nothing 'obj variable released

%>

and I get the following error message:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'localhost' (10022)
/test99.asp, line 19


Any ideas on things I could check would be most appreciated.

Dave

Reply With Quote
  #4  
Old February 4th, 2004, 05:59 AM
8tv_Gary 8tv_Gary is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 8tv_Gary User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I believe you haven't install MySQL ODBC 3.51 Driver, that's why you can't connect to MySQL Database from ASP. To check whether you have install the driver, you can goto:

Control Panel>Administration Tools>Data Sources(ODBC)>User DSN

If the driver had been installed, it should appear on the driver list....else you can download the driver from URL and install it. It should solve your problem....

Reply With Quote
  #5  
Old February 5th, 2004, 04:31 AM
amittal amittal is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: web Development
Posts: 44 amittal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
You can also try creating DSN for that connection.If that work you shd be able to connect directly using ASP.

Reply With Quote
  #6  
Old February 11th, 2004, 12:26 PM
judo1 judo1 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Victoria, BC, Canada
Posts: 8 judo1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to judo1
Account

Check the account priveleges on the SQL server. You may need to specify that you have the right credentials to login.

Reply With Quote
  #7  
Old August 16th, 2004, 03:12 PM
flassiman flassiman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 flassiman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

I ran your code OK, but only after correcting the conn.execute to my_conn.execute.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > unable to connect to mysql database using asp


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway