By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

WHERE clause constraint with 2 columns

P: n/a
I need an SQL statemnt in access to serv me in authentication form.
What is the syntax for it?

this is what I wrote & I got error.

string sqlFindUserPswrd = "SELECT COUNT(UserName) AS UserNameExists " +
"FROM usersTbl " +"WHERE (UserName='" + username + "' , Password = "
+ password + ")";

TIA,

Ronen

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
<ro****@tauex.tau.ac.il> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I need an SQL statemnt in access to serv me in authentication form.
What is the syntax for it?

this is what I wrote & I got error.

string sqlFindUserPswrd = "SELECT COUNT(UserName) AS UserNameExists " +
"FROM usersTbl " +"WHERE (UserName='" + username + "' , Password = "
+ password + ")";

In VBA? Well some of those joins look unnecessary but the join character is
"&" not "+". Not tested, but how about:

string sqlFindUserPswrd = "SELECT COUNT(UserName) AS UserNameExists FROM
usersTbl WHERE (UserName = '" & username & "' AND Password = '" & password &
"')";

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #2

P: n/a
Br
Keith <ke*********@baeAWAYWITHITsystems.com> wrote:
<ro****@tauex.tau.ac.il> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I need an SQL statemnt in access to serv me in authentication form.
What is the syntax for it?

this is what I wrote & I got error.

string sqlFindUserPswrd = "SELECT COUNT(UserName) AS UserNameExists
" + "FROM usersTbl " +"WHERE (UserName='" + username + "' , Password
= " + password + ")";
In VBA? Well some of those joins look unnecessary but the join
character is "&" not "+". Not tested, but how about:
Unless he's writing a stored procedure or something?
string sqlFindUserPswrd = "SELECT COUNT(UserName) AS UserNameExists
FROM usersTbl WHERE (UserName = '" & username & "' AND Password = '"
& password & "')";


And if you are really interested in making secure watch out for SQL
injection exploits :)
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #3

P: n/a
Br
Keith <ke*********@baeAWAYWITHITsystems.com> wrote:
<ro****@tauex.tau.ac.il> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I need an SQL statemnt in access to serv me in authentication form.
What is the syntax for it?

this is what I wrote & I got error.

string sqlFindUserPswrd = "SELECT COUNT(UserName) AS UserNameExists
" + "FROM usersTbl " +"WHERE (UserName='" + username + "' , Password
= " + password + ")";

In VBA? Well some of those joins look unnecessary but the join
character is "&" not "+". Not tested, but how about:

string sqlFindUserPswrd = "SELECT COUNT(UserName) AS UserNameExists
FROM usersTbl WHERE (UserName = '" & username & "' AND Password = '"
& password & "')";


ps.

COUNT(UserName) seems a bit redundant as if there is no match no record
is returned....

Just use a simple select statement and test for EOF.
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.