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
.Open
End With
RS.Open "select * from TB_Users", CNN, adconstatic, adLockOptimistic
MsgBox "Connection Established" '& " -" & CNN.Provider, vbOKOnly + vbInformation, "Connection"
'Debug.Print "connection Established"
frmLogin.Show
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
End Sub

Private Sub cmdOK_Click()
RS.Open ("Select * from TB_Users 'Where Name = " & TXTUserName & " and Password=" & TXTPassword & ""), CNN
If RS.EOF = False Then
FRMMDIMain.Show
Unload Me
Else
MsgBox "Invalid Password, try again!", , "Login"
TXTUserName.SetFocus
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

Manojthahal

Hi,

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..

REgards
Veena

and thr is no need of recordset declaration

check it

u already declared in module i think

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

This article has been dead for over six months. Start a new discussion instead.