473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

WHERE clause constraint with 2 columns

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
3 1414
<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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: steve | last post by:
To gain performance, do I need to index ALL the fields in the where clause. Say we have a query like: select stuff from table where field1=.. and field2=... If field1 selection substantially...
3
by: A.V.C. | last post by:
Hello, I found members of this group very helpful for my last queries. Have one problem with CASE. I can use the column name alias in Order By Clause but unable to use it in WHERE CLAUSE. PLS...
2
by: adammitchell | last post by:
How can you indicate that a FOREIGN KEY constraint references two columns in two different tables? "SQL Server Books Online" show an example of how to reference two columns in the SAME table:...
7
by: Brian Keating | last post by:
Hi there, Is it possible to add a unique constraint on two columns in a table, so that the constraint is a composite of the two? i.e. these two columns together should be unique...? i.e....
3
by: Brad Wood | last post by:
I have this method declaration: private SomeType getSomething<T>( T spec ) where T: String, MemoryStream The compiler error I get is: 'string' is not a valid constraint. A type used as a...
2
by: Jim.Mueksch | last post by:
I am having a problem with using calculated values in a WHERE clause. My query is below. DB2 gives me this error message: Error: SQL0206N "APPRAISAL_LESS_PRICE" is not valid in the context where...
28
by: davinski | last post by:
So thanks to another member here I got my view sorted out :D but now that I've begun to write my stored proc I've ran into another problem! Basically, my stored proc takes about 30 variables and...
4
by: Jane T | last post by:
I appreciate how difficult it is to resolve a problem without all the information but maybe someone has come across a similar problem. I have an 'extract' table which has 1853 rows when I ask for...
3
by: bilbo | last post by:
Can anybody help me understand why I get the error "Syntax error in CONSTRAINT clause"? I get it in Access 2003 and Access 2007. Both are clean installs with no add-ins Running this code in...
2
by: Jack | last post by:
Hi, Performance-wise, is there a difference between these 2 clauses? I assume a large database... 1) With the WHERE clause: Select FLD1, FLD2, FLD3 From myFile Where FLD1 = 1 And FLD2 = 1
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.