473,242 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

Can't connect to localhost using odbc string connections

Hello,

Here's my problem. I cannot connect to mysql database using odbc string
connections or dns. I keep getting a "cannot connect to mysql server localhost." I'm running windows XP Pro and have installed IIS as my server. I have installed Mysql 5.0 and mysql ODBC driver 3.51.12 in their default locations. Database is up and running okay, as I've been able to create databases and tables and access
them via the command prompt and mysql administrator. I have also successfully created and tested odbc link to these databases in odbc data source administrator.

I'm fairly new to this so I'm going to include the script I've been trying to use.
Maybe it's just my syntax. I'm trying to do this in ASP, and there are two things I 'm unsure of. The first one being the server parameter. Is localhost correct? Also, I am unsure if I have to include the complete path for the database parameter, and it's so where is the actual file that I need to point to?
I have searched relentlessly for a solution to this problem and I'm about ready to
throw in the towel. Any help would be greatly appreciated.

Thank you very much,
Mike
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. 'declare the variables 
  3. Dim Connection
  4. Dim ConnString
  5. Dim Recordset
  6. Dim SQL
  7.  
  8. 'declare the SQL statement that will query the database
  9. SQL="SELECT *tablename"
  10.  
  11. 'define the connection string, specify database driver
  12. ConnString="DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;"
  13. "DATABASE=C:\Program Files\MySQL\MySQL Server 5.0\data\database folder name;" &_
  14. "UID=root;PASSWORD=password; OPTION=3"
  15.  
  16. 'create an instance of the ADO connection and recordset objects
  17. Set Connection=Server.CreateObject("ADODB.Connection")
  18. Set Recordset=Server.CreateObject("ADODB.Recordset")
  19.  
  20. 'Open the connection to the database
  21. Connection.Open ConnString
  22.  
  23. 'Open the recordset object executing the SQL statement and return records 
  24. Recordset.Open SQL,Connection
  25.  
  26. 'first of all determine whether there are any records 
  27. If Recordset.EOF Then 
  28. Response.Write("No records returned.") 
  29. Else 
  30. 'if there are records then loop through the fields 
  31. Do While NOT Recordset.Eof   
  32. Response.write Recordset("user_id")
  33. Response.write Recordset("last_name")
  34. Response.write Recordset("first_name")
  35. Response.write "<br>"    
  36. Recordset.MoveNext     
  37. Loop
  38. End If
  39.  
  40. 'close the connection and recordset objects freeing up resources
  41. Recordset.Close
  42. Set Recordset=nothing
  43. Connection.Close
  44. Set Connection=nothing
  45. %>
Oct 25 '06 #1
2 9351
bharad
7
Try giving just the database name; why give absolute dir path?

Next time read the Posting Guidelines before you post in this forum and enclose your code within PHP or CODE tags!! - Ronald :cool:

Hello,

Here's my problem. I cannot connect to mysql database using odbc string
connections or dns. I keep getting a "cannot connect to mysql server localhost." I'm running windows XP Pro and have installed IIS as my server. I have installed Mysql 5.0 and mysql ODBC driver 3.51.12 in their default locations. Database is up and running okay, as I've been able to create databases and tables and access
them via the command prompt and mysql administrator. I have also successfully created and tested odbc link to these databases in odbc data source administrator.

I'm fairly new to this so I'm going to include the script I've been trying to use.
Maybe it's just my syntax. I'm trying to do this in ASP, and there are two things I 'm unsure of. The first one being the server parameter. Is localhost correct? Also, I am unsure if I have to include the complete path for the database parameter, and it's so where is the actual file that I need to point to?
I have searched relentlessly for a solution to this problem and I'm about ready to
throw in the towel. Any help would be greatly appreciated.

Thank you very much,
Mike
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. 'declare the variables 
  3. Dim Connection
  4. Dim ConnString
  5. Dim Recordset
  6. Dim SQL
  7.  
  8. 'declare the SQL statement that will query the database
  9. SQL="SELECT *tablename"
  10.  
  11. 'define the connection string, specify database driver
  12. ConnString="DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;"
  13. "DATABASE=C:\Program Files\MySQL\MySQL Server 5.0\data\database folder name;" &_
  14. "UID=root;PASSWORD=password; OPTION=3"
  15.  
  16. 'create an instance of the ADO connection and recordset objects
  17. Set Connection=Server.CreateObject("ADODB.Connection")
  18. Set Recordset=Server.CreateObject("ADODB.Recordset")
  19.  
  20. 'Open the connection to the database
  21. Connection.Open ConnString
  22.  
  23. 'Open the recordset object executing the SQL statement and return records 
  24. Recordset.Open SQL,Connection
  25.  
  26. 'first of all determine whether there are any records 
  27. If Recordset.EOF Then 
  28. Response.Write("No records returned.") 
  29. Else 
  30. 'if there are records then loop through the fields 
  31. Do While NOT Recordset.Eof   
  32. Response.write Recordset("user_id")
  33. Response.write Recordset("last_name")
  34. Response.write Recordset("first_name")
  35. Response.write "<br>"    
  36. Recordset.MoveNext     
  37. Loop
  38. End If
  39.  
  40. 'close the connection and recordset objects freeing up resources
  41. Recordset.Close
  42. Set Recordset=nothing
  43. Connection.Close
  44. Set Connection=nothing
  45. %>
Nov 1 '06 #2
Try giving just the database name; why give absolute dir path?

yep, finally figured that one out. Also, after a long end and painstaking search I finally ran across an article that talked about com objects. This jogged my memory and I realized the very first time I tried to run this script(with the correct database name, no path) my firewall alerted me to the possibility of a Trojan, so I blocked all access to my own script. Pretty funny huh? If I hadn't run across that one article, I might still be pulling my hair out.

Thanks for replying,
I'm sure I'll be needing to talk with all of you again soon,
mike
Nov 2 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ragtimer | last post by:
I've been trying to build a DAO.QueryDef.Connect string, building it from a user ID and password string obtained previously by a log-in dialog box, using it to log in to an Oracle database through...
3
by: colin.anderson | last post by:
Hi I am trying to refresh table links at startup in an Access 2002 application. The following code is based on a number of articles posted in this group but this does not seem to work: ...
5
by: Jim W | last post by:
I have an ASP.NET app that has very slow connect times using TCPClient, or the Socket class, or even calling a COM object that uses C socket calls on certain similar XP SP2 boxes. On those...
0
by: Clodoaldo Pinto | last post by:
Can't connect to postgresql server php error log message: PHP Warning: pg_connect() : Unable to connect to PostgreSQL server: could not connect to server: Permission denied\n\tIs the server...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
3
by: LamSoft | last post by:
I am not going to write a aspx to connect a SQL Server... but it tries to connect the SQL Server... Some of the Code.. protected void LoginButton_Click(object sender, EventArgs e) { if...
6
by: xx75vulcan | last post by:
Hi, I have two seperate production machines that I'm trying to get to play nicely together. This setup has worked for years before - until recently bother machines were reformatted, and...
3
by: evonczoernig | last post by:
I Can not connect to Oracle 10g XE from ASP perscript web page on IIS 6 running on server 2003. I have set up the database and the ODBC connections. The ODBC connection is workinh and I can connect...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.