I am started a new with VB6 Access project. I am connected database with ADODB, DSN Method that Code Given below.

'================In module ==============
'============ Connection With Database ===============

Public CNN As New ADODB.Connection
Public RS As New ADODB.Recordset
Public cString As String

Public Sub Main()
Set CNN = New ADODB.Connection
cString = "DSN=Customer"
With CNN
.ConnectionString = cString
.CommandTimeout = 20
.CursorLocation = adUseClient
End With
RS.Open "select * from TB_Users", CNN, adconstatic, adLockOptimistic
MsgBox "Connection Established" '& " -" & CNN.Provider, vbOKOnly + vbInformation, "Connection"
'Debug.Print "connection Established"
End Sub

This is writted in Module. This is working properly. But My problem is I can't get username and Password from from Table to my login form. I have written some code that is given below.

'================In FRMLogin===============
Dim RS As New ADODB.Recordset

Private Sub cmdCancel_Click()
End Sub

Private Sub cmdOK_Click()
RS.Open ("Select * from TB_Users 'Where Name = " & TXTUserName & " and Password=" & TXTPassword & ""), CNN
If RS.EOF = False Then
Unload Me
MsgBox "Invalid Password, try again!", , "Login"
End If
End Sub


When I run this getting Debug Messege

Runtime Error - '-2147217904(800440e10)'

[Microsoft][ODBC Microsoft Access Driver] Too few Parameters. Expected 2.

I can't understand this messege ..... Please Help Me... Plese

Also please give the source code to insert data to Table and update data.... Please

With Regards


Re: Run Time Error 2147217904(80040e10) 80 80


Check the query in OK button:

RS.Open ("Select * from TB_Users Where Name = '" & TXTUserName & "' and Password='" & TXTPassword & "'"), CNN

There is an extra single quote before Where. and Wrap the Text Fields with Single quote..


Re: Run Time Error 2147217904(80040e10) 80 80

and thr is no need of recordset declaration

check it

u already declared in module i think

Re: Run Time Error 2147217904(80040e10) 80 80

Google the error message (without the number in paranthesis) and you'll see.

Be a part of the DaniWeb community

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