Click here to Skip to main content
15,904,823 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have got silly problem when i check username password in my login form but .... But its not working...

What I have tried:

VB
Dim ole as new oledb.oledbcommnd()
ConnectData() ' database connection procedure
ole.connection = conn
Ole.commandText = "select * from login where user = '@usern' and pass = '@pass'"

Ole.parameters.add("@usern",oledbtype.varchar,30).value = username 'username is string type variable
ole.parameters.add("@pass",oledbtype.varchar,30).value = password 'password is string type variable

Dim dr as oledb.oledbdatareader = ole.executereader

if dr.read() then
   dr.close
   Return true
Else
   Dr.close
   Return false
End if
Posted
Updated 17-Oct-16 8:23am
v3
Comments
Naveen Roy 17-Oct-16 14:24pm    
Its always return false even i type correct username password

1 solution

When you use parameters, you don't use apostrophes for the values. So instead of
VB
Ole.commandText = "select * from login where user = '@usern' and pass = '@pass'"

try
VB
Ole.commandText = "select * from login where user = @usern and pass = @pass"

Another thing is that you should properly dispose the objects. The easiest way is to use using block. For examples, have a look at Properly executing database operations[^]

And the third thing is that you seem to store the password as plain text. If this really is the case, you should fix it as soon as possible. Have a look at Password Storage: How to do it.[^]
 
Share this answer
 
v3
Comments
Naveen Roy 17-Oct-16 14:29pm    
I know that i have to dispose all object ... But how can i type all the code from mobile.... Well thank you your answer is correct
Wendelius 17-Oct-16 14:30pm    
Glad if it helped. However, note the comment on storing passwords.
Maciej Los 17-Oct-16 15:43pm    
5ed!
Wendelius 17-Oct-16 23:21pm    
Thanks

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