Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear friends
I was trying to make a login form in vb6 and access 2007. It worked fine but it is not case sensitive. If i type username or password in lower case or uppercase it is logging me in.
How can i make it case sensitive.
It it possible on Vb6.
I tried strcomp() but no success.
Please help

Sarfaraz
Posted
Comments
Ashok19r91d 28-Dec-12 0:09am    
What's the Query you Used to Retrieve login Details?
Comment out Here... It helps to Understand your Faults better...
sarfarazbhat 31-Dec-12 1:04am    
Sir Pls Reply and help me in this regard!
sarfarazbhat 28-Dec-12 8:50am    
Connection

Set rs = New ADODB.Recordset
rs.Open "select * from login where Username='" & Text1.Text & "'" _
& " and Password='" & Text2.Text & "'", Con, adOpenDynamic, adLockOptimistic
Text1.SetFocus

If Not rs.EOF Then

MsgBox "OK"


Else
MsgBox "Invalid username or password", vbInformation, "Login..."
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus

rs.Close
End If
I tried this the following function also but no success
StrComp(strVal1, strVal2, vbTextCompare)
StrComp(strVal1, strVal2, vbBinaryCompare)
StrComp(strVal1, strVal2, vbDatabaseCompare)
Ashok19r91d 31-Dec-12 1:18am    
I've Updated SOlution, Comeback and Check...
Don't forget to Accept Solution if it Works...

Your Mistake is that you've Send Username with Password to Check in Database,
All SQL Queries and it's Paramaeters are not Case Sensitive...
So Now I've Updated your Source Which send UserName to Database and Retrieve Password from it, After that You can compare both text using Simple IF condition...
Here's my Solution, It'll work...

VB
Set rs = New ADODB.Recordset
Qry = "SELECT Password FROM Login WHERE UserName = '" & Text1.Text & "'"
rs.Open Qry, Con, adOpenDynamic, adLockOptimistic    
If Not rs.EOF Then
    If rs(0) = Text2.Text Then  ' rs(0) may be written as rs.Fields(0) try both
        MsgBox "OK" 
    Else
        Msgbox "Invalid Username or Password", vbInformation, "Login..."
    End If
Else
    MsgBox "Invalid Username or Password", vbInformation, "Login..."
    Text1.Text = ""
    Text2.Text = ""
End If
rs.Close
Text1.SetFocus     
 
Share this answer
 
Comments
sarfarazbhat 31-Dec-12 12:25pm    
Thank you soooo much sir.
Wish you a very happy and prosperous new year 2013.
 
Share this answer
 
Comments
sarfarazbhat 24-Dec-12 12:34pm    
No success. Since i need to check the username and password from the access database table.
Please if you can give some code as how to check the textbox(username) and textbox(password) and compare the values from login table in Access 2007.
Thanks
Hi Sarfaraz

You are doing well,For archive that, do one more thing write a function for encryption and decryption

Encrypt it, while storing username and password.

During log in, first you have to encrypt the user name and password for comparison.

If you want to show User Name some where like Audit trail at that time you have to Decrypt the username.

Find below link for encryption/Decryption....
http://support.microsoft.com/kb/821762[^]
http://www.developerfusion.com/code/157/encryptdecrypt/[^]

Regards,
Vijay
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900