Search code examples
mysqlvb6mysql-error-1045

Connecting to MySQL from a VB6 application


I am trying to connect to a local MySQL database from a VB6 application. Having read the answer given in this question, Connecting VB to MySQL I have set up my connection thus...

Private database_connection As ADODB.Connection
Set database_connection = New ADODB.Connection
database_connection.ConnectionString = _
"Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=mydb; " _
              " Username=myuser; Password=mypass; Option=3"
database_connection.Open

This gives me an error...

(1) Error#: -2147467259
    Desc. : [MySQL][ODBC 3.51 Driver]Access denied for user 'ODBC'@'localhost' (using password: YES)
    Source: Microsoft OLE DB Provider for ODBC Drivers
    Native Error: 1045
    SQL State: S1000
    Help Context: 0
    Help File: 

Is this the right approach? And if so, it appears I need to create an account in the database for ODBC. Is that the case, or is there something else wrong somewhere?


Solution

  • Use User=myuser; instead of Username=myuser;