Hi,
I'm developing a VB6 application connecting to a MySQL database. I'm getting run-time error 3001: arguments are of the wrong type, are out of an acceptable range, or are in conflict of each other.

I'm using the ODBC driver from MySQL. I would appreciate if anyone could spot where I'm going wrong as this is the first time I'm using VB6 to connect to a DB.

Private Sub Command1_Click()
    Dim dbuser As String, password As String, dbname As String, hostname As String
    Dim sql As String
   
    Open App.Path & "\settings.txt" For Input As #1
        Line Input #1, dbuser
        Line Input #1, password
        Line Input #1, dbname
        Line Input #1, hostname
    Close #1
    
    Set conn = New ADODB.Connection
    Set login = New ADODB.Recordset
    
    conn.Open "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=" & hostname & ";" & "DATABASE=" & dbname & ";" & "UID=" & dbuser & ";" & "PWD=" & password & ";"
       
    sql = "SELECT * FROM tblUser WHERE user=& txtUsername.Text & AND password=& txtPassword.Text;"
        
    login.Open conn, sql
    
End Sub

Cheers,

Recommended Answers

All 2 Replies

Where is the name??? When you create an ODBC DSN you give it a name. I see where you supply which driver but not its name.

Then, since you are using ADO, you could if you wanted, use a DSN Less connection string... see http://www.connectionstring.com

Good Luck

Your select statement is incorrect. Try the following -

'Your Sql Statement
sql = "SELECT * FROM tblUser WHERE user=& txtUsername.Text & AND password=& txtPassword.Text;"
'Try
sql = "SELECT * FROM tblUser WHERE user=" & "'" &  txtUsername.Text & "'" & " AND password=" & "'" & txtPassword.Text & "'" & ";"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.