I am using visual basic 6. I have a button created which when pressed should display all the entries of the table. I am using following code to connect to MySQL database. I have used the Microsoft Remote Data Services as my reference
code:
Private Sub cmdConnectMySQL_Click()
Dim cnMySql As New rdoConnection
Dim rdoQry As New rdoQuery
Dim rdoRS As rdoResultset
cnMySql.CursorDriver = rdUseOdbc
cnMySql.Connect = "uid=root;pwd=;
server=localhost; driver={MySQL ODBC 3.51 Driver};
database=demo;dsn=;"
cnMySql.EstablishConnection
With rdoQry
.Name = "selectUsers"
.SQL = "select * from user"
.RowsetSize = 1
Set .ActiveConnection = cnMySql
Set rdoRS = .OpenResultset(rdOpenKeyset, rdConcurRowVer)
End With
Do Until rdoRS.EOF
With rdoRS
rdoRS.MoveNext
End With
Loop
rdoRS.Close
cnMySql.Close
End Sub
I am not able to connect to the database. How do I connect?