Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

connection to Access from VB6

I have a loginform with a working loginscript. You can see it below..

What I would like to do is this:
When user and password is entered correct, I would like to show the full name of the user in the welcome MsgBox.
With this code I only show the user name that was entered to log in..
My database is set up with User, Password, FullName

any help? anyone?

On Error GoTo ErrHandler
'Connect to database
strCNString = "Data Source=" & App.Path & "\Users.mdb"
cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
cn.ConnectionString = strCNString
cn.Properties("Jet OLEDB:Database Password") = "mypassword"
cn.Open
'Open recordsource
With rs

.Open "Select * from Users where User='" & user.Text & "' and password='" & pass.Text & "'", cn, adOpenDynamic, adLockOptimistic
'Check username and password

If .EOF Then
MsgBox "Access Denied...Please enter correct password!", vbOKOnly + vbCritical, "Security Login"
user.Text = ""
pass.Text = ""
user.SetFocus
cn.Close
Else
Txt = "" & " " & UCase$(user.Text) & ""
MsgBox "Welcome!!!" & Txt, vbOKOnly + vbExclamation, "Security Login"
cn.Close
Unload Me
Mainform.Show

End If
End With
[1494 byte] By [lord_saroman] at [2007-11-11 8:29:39]
# 1 Re: connection to Access from VB6
Try this out
username: teuser
password: 123456

See attached project i commented as much of the code to help explain
jim12345 at 2007-11-11 17:25:28 >
# 2 Re: connection to Access from VB6
So darn easy... I changed just a few lines in my code from your code.
IT worked!!

THanks m8
lord_saroman at 2007-11-11 17:26:28 >