PDA

View Full Version : ASP COUNT()



pucca
March 8th, 2006, 04:36 AM
Hi, I need to check a database for double entry on name and surname... For example, the same person can't enter the competition. This is my code.. Whats wrong?

rstotal.Open "Select COUNT(*) as total from comptbl WHERE cname='" & Request("name") & "' and csurname='" & Request("surname"), conn

Please help.
Thanks!
Its actually a sql question.. oops. sorry....

antizip
March 8th, 2006, 09:45 AM
Well if you're just lookin to see if there already exists an entry you dont need to count ...

rsTotal.Open="SELECT * FROM comptbl WHERE cname='" & Request("name") & "' and csurname='" & Request("surname") & "'", conn

if not rsTotal.eof then
...
end if

But I think your question is cuz there's an error in the sql ...

rstotal.Open "Select COUNT(*) as total from comptbl WHERE cname='" & Request("name") & "' and csurname='" & Request("surname") & "'", conn