2

I have to do a MySQL-Database connection to a remote server using ASP. When I use normal PHP everything is fine. If I use following ASP code

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=MSDASQL;" & _  
           "Driver={SQL Server};" & _
           "Server=mysqlsvr.domain.com;" & _
           "Database=database1;" & _
           "Uid=username;" & _
           "Pwd=password"

I always get the error that the database is not reachable or permission denied... but with PHP everything works fine?! Do you know where the problem is?

Thanks in advance. Regards.

2
  • 1
    Are ASP and PHP on the same server? Commented Jan 25, 2013 at 13:12
  • 3
    if the db is MySQL why are you using Driver={SQL Server};? Commented Jan 25, 2013 at 13:17

2 Answers 2

1

connection string is wrong. Try:

"DRIVER={MySQL ODBC 3.51 Driver}; SERVER=mysqlsvr.domain.com; DATABASE=database1; UID=username;PASSWORD=password;"

You need Mysql ODBC driver installed

Sign up to request clarification or add additional context in comments.

Comments

0

Connect without a DSN

'define the connection string, specify database driver

ConnString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=Your_Mysql_DB; " &_ "UID=mysql_username;PASSWORD=mysql_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")

Connection with DSN

'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 "DSN=dsn_name"

'Open the recordset object executing the SQL statement and return records

Recordset.Open SQL,Connection

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.