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?

2 Answers

  1. Keith- Reply

    2019-11-15

    Use User=myuser; instead of Username=myuser;

  2. Ken- Reply

    2019-11-15

    Check your username/password and if that username has accesrights to connect to database.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>