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
- <%
- 'declare the variables
- Dim Connection
- Dim ConnString
- Dim Recordset
- Dim SQL
- 'declare the SQL statement that will query the database
- SQL="SELECT *tablename"
- 'define the connection string, specify database driver
- ConnString="DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;"
- "DATABASE=C:\Program Files\MySQL\MySQL Server 5.0\data\database folder name;" &_
- "UID=root;PASSWORD=password; OPTION=3"
- 'create an instance of the ADO connection and recordset objects
- Set Connection=Server.CreateObject("ADODB.Connection")
- Set Recordset=Server.CreateObject("ADODB.Recordset")
- 'Open the connection to the database
- Connection.Open ConnString
- 'Open the recordset object executing the SQL statement and return records
- Recordset.Open SQL,Connection
- 'first of all determine whether there are any records
- If Recordset.EOF Then
- Response.Write("No records returned.")
- Else
- 'if there are records then loop through the fields
- Do While NOT Recordset.Eof
- Response.write Recordset("user_id")
- Response.write Recordset("last_name")
- Response.write Recordset("first_name")
- Response.write "<br>"
- Recordset.MoveNext
- Loop
- End If
- 'close the connection and recordset objects freeing up resources
- Recordset.Close
- Set Recordset=nothing
- Connection.Close
- Set Connection=nothing
- %>