MySQL Forums
Forum List  »  Connector/ODBC

-- Can't get ODBC connection
Posted by: Jim Bunton
Date: February 10, 2005 09:57AM

-- Can't get a connection via ODBC ---

I Have Mysql 4.1 installed on Windows 2000
I can access it from the console and MySqlAdministrator and MySql Query Browser

I want to connect to it using OBBC

I have installed the ODBC 3.51 Driver using MyODBC-3.51.10-2-win.msi

I have created a ODBC Data Source called MySqlTest
using the configure dialogue TEST button the Data Source reports a successful connection
[using root and localhost]

What I want to do is to connect to the Database using ASP
using VbScript

*** Code ******************************************

'Create Connection object
Set objConBookings= Server.CreateObject("ADODB.Connection")

'Assemble Connect String for MyODBC 3.51:
Constr = "Provider=MSDASQL; "
ConStr = ConStr & "DRIVER=MySqlTest; "
ConStr = ConStr & "SERVER=localhost; "
ConStr = ConStr & "DATABASE=test; "
ConStr = ConStr & "USER=root; "
'The password is "" at the moment
ConStr = ConStr & "PASSWORD="
ConStr = ConStr & "OPTION=3; "

'Open a connection with the connection object
' REFUSES TO work!
objConBookings.open (constr)

** END Code ***************************************

ERROR IS:-
odbc driver manager - Data source not found and no default driver specified
/snolabs/opentest.asp, line 42
------------------------------------------

As an alternative
I have attempted to connedt using MsAccess2000

******* CODE *******************************
Private Sub mysqlco_Click()
Dim myconn As New ADODB.Connection
Dim myrs As New Recordset
Dim mySQL As String
Dim myrows As Long

'This line fails - Catastrophic error!
myconn.Open "DSN=MySqlTest"

mySQL = "SELECT * from owner"

myrs.Source = mySQL
Set myrs.ActiveConnection = myconn
myrs.CursorLocation = adUseClient
myrs.Open
myrows = myrs.RecordCount
myrs.Close
myconn.Close

End Sub

*** END CODE *******************************

----------------------------------------

Options: ReplyQuote


Subject
Written By
Posted
-- Can't get ODBC connection
February 10, 2005 09:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.