Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with this sql statement 1

Status
Not open for further replies.

frogggg

Programmer
Jan 17, 2002
182
US
Here is the statement in question:

rsValidatePassword.setSQLText("SELECT CandidateContactInfo.* " _
& "FROM CandidateContactInfo " _
& "WHERE UserName='" & Request.QueryString("txtUserName") & "'OR UserName='" & session("UserName") _
& "' AND Password='" & Request.QueryString("txtPassword") & "'OR Password='" & session("Password") & "'")

I intended to be able to offer two options for each username and password. Instead, the OR seems to be being applied to the password too, so that if the user enters just the username or just the password or the wrong password, the record comes up anyway.

What do I have to do to allow the username to be either from the querystring or the session variable and the password to be either from the querystring or the session variable but requiring both the correct username and password.

I hope that wasn't too wordy. Thanks for any help.
 
Put brackets in to group your OR statements together:

rsValidatePassword.setSQLText("SELECT CandidateContactInfo.* " _
& "FROM CandidateContactInfo " _
& "WHERE (UserName='" & Request.QueryString("txtUserName") & "'OR UserName='" & session("UserName") _
& "') AND (Password='" & Request.QueryString("txtPassword") & "'OR Password='" & session("Password") & "'"))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top