7 Years
Discussion Span
Last Post by AndreRet
Featured Replies

Ok can you provide me sample coding for login a user by checking user exists in users table i have tried but no luck

i am trying some thing like this

dim db as database
dim rs as recordset

on form load i am connecting with database like this
my connecting string here and
set rs = db.openrecordset("Users")

Then i used this coding on btnlogin

select query here

but i didn't successed i please help me waiting for you reply


Try the following -

Dim cnPrint As ADODB.Connection
    Set cnPrint = New ADODB.Connection
    Dim rsPrint As ADODB.Recordset
    Set rsPrint = New ADODB.Recordset
    Dim MyCon As String
    MyCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyData.MDB;Persist Security Info=False"
    cnPrint.Open MyCon
    If rsPrint.State = adStateOpen Then rsPrint.Close
    rsPrint.Open "SELECT * FROM MyTable WHERE UserType =" & "'" & text1.Text & "'", cnPrint, adOpenStatic, adLockOptemistic


    rsPrint.Open "SELECT * FROM MyTable WHERE UserYesNo =" & "'Yes'", cnPrint, adOpenStatic, adLockOptemistic
This question has already been answered. 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.