Solved

Can’t connect to MySQL with ASP

Posted on 2007-03-30
24
854 Views
Last Modified: 2012-06-22
I’m trying to connect to MySQL on my local computer with ASP on my website. I get this error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on '********.dyndns.org' (10060)
/******.asp, line 17


Here is my ASP code:

<%
Dim oConn, oRs
Dim qry, connectstr
Dim db_name, db_username, db_userpassword
Dim db_server

db_server = "*******.dyndns.org" 'db_server = "mysql.secureserver.net"
db_name = "******" 'db_name = "your_dbname"
db_username = "*****" 'db_username = "your_dbusername"
db_userpassword = "*****" 'db_userpassword = "your_dbpassword"
fieldname = "your_field" 'fieldname = "your_field"
tablename = "your_table" 'tablename = "your_table"

connectstr = "Driver={MySQL ODBC 3.51 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PASSWORD=" & db_userpassword

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr

'qry = "SELECT * FROM " & tablename

'Set oRS = oConn.Execute(qry)

'if not oRS.EOF then
'while not oRS.EOF
'response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "<br>"
'oRS.movenext
'wend
'oRS.close
'end if

'Set oRs = nothing
Set oConn = nothing

%>



My website is hosted on a Windows server through GoDaddy.com
MySQL version: 4.0.26

I’m able to connect remotely to MySQL; I’ve done it with MySQLAdministrator, I just can’t do it with the ASP code.
0
Comment
Question by:steveca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
  • 6
  • +1
24 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 18825297
just to verify... when using the MySQLAdministrator are you connecting to the database via *******.dyndns.org?

some other thing to try are:
<%
    cst = "Provider=MySQLProv;" & _
        "Data Source=<x.x.x.x>;" & _
        "Database=<dbname>;" & _
        "User Id=<uid>;" & _
        "Password=<pwd>"
%>

or

<%
    cst = "Driver={MySQL};" & _  
        "Server=<x.x.x.x>;" & _
        "Database=<dbname>;" & _
        "Uid=<uid>;" & _
        "Pwd=<pwd>"
 %>

or

<%
    cst = "Driver={MySQL ODBC 3.51 Driver};" & _
        "Server=<x.x.x.x>;" & _
        "Database=<dbname>;" & _
        "Uid=<uid>;" & _
        "Pwd=<pwd>;"
%>


please make sure to replace the necesary info
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18825316
also.  Another thing to try would be to use the IP address instead of the dyndns.org address

p.s.  Since you are hosting through GoDaddy, I am assuming you have your domain name registered there?  If this is the case why in the name of all that is good would you use dyndns.org?  You could simply setup a CNAME, or A record to point to the MySQL server....
0
 
LVL 9

Expert Comment

by:fuzzboxer
ID: 18825339
If it is on your local machine, you should use localhost.

db_server=localhost;
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 9

Expert Comment

by:fuzzboxer
ID: 18825357
You may need to specify the port number in your connection string.
0
 

Author Comment

by:steveca
ID: 18825651
kevp75,

Yes, when I used MySQLAdministrator to connect I also used the server address *******.dyndns.org.

The MySQL database is located on a computer in my home. The *******.dyndns.org allows me a consistent address if my IP address changes.

I’m trying to write ASP code that will sit on the GoDaddy server, as part of my website there. The ASP code will reach out to my computer here and get information from the MySQL database to be used in the creation of content on my website.
0
 

Author Comment

by:steveca
ID: 18825664
fuzzboxer,

I've tried appending the port number to the server address, but it didn't work either.
0
 

Author Comment

by:steveca
ID: 18825737
Here is the error message I get when I append the port number:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[MySQL][ODBC 3.51 Driver]Unknown MySQL server host '*********:3306' (11004)
/*****.asp, line 17
0
 
LVL 9

Expert Comment

by:fuzzboxer
ID: 18825923
Hmm, could be a syntax error.  Try this:  connectstr = "Driver={MySQL ODBC 3.51 Driver};SERVER=db_server;DATABASE=db_name;UID=db_username;PASSWORD=db_userpassword;"
0
 

Author Comment

by:steveca
ID: 18826114
I've tried with the comma at the end and with PWD or PASSWORD. These all give the same original error.

Of the three variation that kevp75 suggested, the first gave this error:

ADODB.Connection error '800a0e7a'
Provider cannot be found. It may not be properly installed.
/********.asp, line 17

The second variation gave this error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/******.asp, line 17

And the third gave the original error message.
0
 
LVL 9

Expert Comment

by:fuzzboxer
ID: 18826260
Add OPTION=3; after the password and try again.
0
 

Author Comment

by:steveca
ID: 18826348
same error still
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18826368
ok.  That means godaddy does not have the drivers installed to connect to a mySQL database.  Your only other options are

A)use MS Access
b)use a different database that they support
0
 
LVL 9

Expert Comment

by:fuzzboxer
ID: 18826383
I found this article on their help section:  http://help.godaddy.com/article.php?article_id=260

Give that a shot.
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18826461
That would only help if he had a file DSN on goDaddy.
0
 
LVL 9

Expert Comment

by:fuzzboxer
ID: 18826500
According to godaddy.com, you have a specific directory for File DSNs called "_dsn".
0
 

Author Comment

by:steveca
ID: 18826526
kevp75,

GoDaddy does have drivers installed. It is possible to set up a MySQL database on their server and connect to that. The issue is that I want to connect to a database on my home computer, not on the website server.
0
 

Author Comment

by:steveca
ID: 18826779
From what I am gathering as I look on various forums, GoDaddy has some kind of firewall in place. Apparently it is possible to work around it using their proxy server, but the GoDaddy help desk doesn't support it at all. Here's a link to what I've found out: http://www.spacialaudio.com/forums/viewtopic.php?t=14731

Any clues where to go from here?
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18826830
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18828829
here is what GoDaddy states:

>>
Thank you for contacting Online Support.

We do not allow external connections to our databases. Use the following directions to access the management tools for your database:

First, log into your customer account:

. Go to the Go Daddy Account Login Page
. Log in using your account username (which may be the same as your customer number) and password

If you have trouble logging in, our password reset form may help you. You can find this form through the following link: Password Reset Form

Once logged in just follow these steps:

. Select 'Web Hosting & Databases' from the 'Hosting & Email' menu at the top of the page
. Click the 'Open' link under the Control Panel column for the hosting account which holds your database
. Click the button for the type of database you are working with

To access the database details (hostname, username, password):
. Click on the username or the 'edit' icon for the database. You can also reset the password and create a DSN from this screen

To edit the database:
. Click the 'Open Manager' button (MySQL/MSSQL)
. MySQL will launch phpMyAdmin and prompt you to login with the username and password for the database
. MSSQL will launch SQL Server Web Admin. You will need to click the [+] next to 'Connection' and click 'Connection'. This will prompt you to login with the username and password for the database

Sincerely,

Mike P.
Online Support Technician
<<
0
 

Author Comment

by:steveca
ID: 18828854
In the meantime I have signed up for a hosting account with another provider and ran into the same issue there, even though at first their suppor desk stated I could make the connection.

So I am looking for yet another hosting provider which will allow me to connect to the database on my home computer. It seems many providers have firewalls in place to prevent this.
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18829318
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 500 total points
ID: 18829319
and if it doesn't work there let me know.  I'll get it working  
0
 

Author Comment

by:steveca
ID: 18829509
SOLUTION:

I switched to www.namespro.ca for the hosting and used the following connection code:

<%
Dim oConn
Dim connectstr

connectstr ="driver={MySQL ODBC 3.51 Driver};server=*********;database=*****;uid=**********;password=***********"

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr

Set oConn = nothing
%>

Thanks kevp75 for sticking with me through this!
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18829792
:)
glad I could.

Yeah that driver is actually (IMHO) the better one to use.  I've tried all sorts on our servers, and we've actually gotten the best performace by using that one...(it's the actual driver from the makers of mySQL)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can Selenium do Load Testing? 2 60
Mysql query one to many 11 40
Adding Rows to Grid 4 32
web api controller with multiple posts that accept different objects 1 25
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question