Strange Issue with ASP displaying records

J

J P Singh

We have a small application to track holidays of our employees.

strUserId = session("UserId")
strSQL = "SELECT * From holidayrequests where UserId="& strUserId &
" ORDER by Status"

I run the above query which for most part returns the results fine but
occassionally it omits records. i check in the database and these records
are present and when I view the details of the same user through the admin
section of the script all the records are returned.

It only happens with just one user.

Has anyone seen this happen? Any Ideas how to resolve this.

Regards
 
E

Evertjan.

J P Singh wrote on 23 feb 2004 in
microsoft.public.inetserver.asp.general:
strSQL = "SELECT * From holidayrequests where UserId="&
strUserId & " ORDER by Status"

"... WHERE UserId = '" & strUserId & "' ORDER by Status"

A litteral string needs to be quoted in SQL.
 
B

Bob Barrows [MVP]

J said:
We have a small application to track holidays of our employees.

strUserId = session("UserId")
strSQL = "SELECT * From holidayrequests where UserId="&

Evertjan is assuming that UserID is a character field. If it's numeric, then
quoting the search criterion will result in a type mismatch.

I think you need to use some basic debugging and "response.write strsql" so
we can see the actual statement that is resulting in the faulty results.

Bob Barrows

PS. Please read this: http://www.aspfaq.com/show.asp?id=2096
 
E

Evertjan.

Bob Barrows [MVP] wrote on 23 feb 2004 in
microsoft.public.inetserver.asp.general:
Evertjan is assuming that UserID is a character field. If it's
numeric, then quoting the search criterion will result in a type
mismatch.

Right, Bob, not quite bright of me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top