0

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,

Edited by bsewell: n/a

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by AndreRet
0

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

0

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 & "'" & ";"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.