473,399 Members | 3,919 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,399 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 9363
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.