473,729 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't connect to localhost using odbc string connections

2 New Member
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 9386
bharad
7 New Member
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
111mike
2 New Member
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
2103
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 an ODBC connection. The problem I have is that it's intermittent, in that invariably the first time I try to connect I still get the Oracle log-in prompt where the user has to type in all the info again anyway; and on subsequent connections...
3
11766
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: ===CODE SNIPPET START=== For i = 0 To CurrentDb.TableDefs.Count - 1 If Left(CurrentDb.TableDefs(i).NAME, 3) = "tbl" Then
5
2746
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 boxes, if another connection is made within a couple seconds, it is fast. Running the same C# code in a console app connects instantly. Unplugging the network cable allows localhost connections to be instant (?!). Running the same ASP.NET app on...
0
2765
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 running on host &quot;127.0.0.1&quot; and accepting\n\tTCP/IP connections on port 5432? php connection string:
14
7040
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 sql server resides on is not reachable. The error is different depending on the connection string that I use. If I use the following connection string: "server=192.1.1.1; Initial Catalog=master; uid=The_User; password=The_Password; Connect...
11
26611
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 and PEAR is in c:\wamp\php\pear I modified php.ini in the c:\wamp\php directory to reflect the actual path, but even stopping and restarting my server shows the c: \php5\pear path. I can't change it no matter what I do I also tried the...
3
2758
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 (Request.Form == null || Request.Form == "") { Session = "LocalHost"; }
6
5384
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 reinstalled fresh. I know I'm missing a simple setting here somewhere... I have a Win 2003 IIS 6.0 box running as web server, and a Win 2003 IIS 6.0 box running as a web server with SQL 2000 Server installed.
3
3069
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 to it via the ODBC test. I have the same ASP application running on a VISTA workstation and it connects fine. Here is the connection string that works fine on the VISTA PC put I can not get it to work on the server 2003 system. $Conn =...
0
8927
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9428
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9156
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8159
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6026
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4798
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2694
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.