justuptime.com - monitor your servers & websites

check to see if record exists ... prob

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 1 posts

Joined: May 2006

supposed to check for record.

simply returns the "not exists" even when record DOES exust

dim db, sql_check

Set db = Server.CreateObject("ADODB.Connection")
db.Open strdbpath

sql_check = "select email from newsletter where email =' & inventory & '"

Set rs = db.Execute(sql_check)
%>

<%
If rs.eof then
response.write ("email not there")
else
response.write ("email already in db")
end if
%>

'

Greg K's picture
Moderator

He has: 1,667 posts

Joined: Nov 2003

have you tried displaying the actual sql statement that is being executed ie. responce.write (sql_check)' right before executing the query. Then manully run that on the database.

You could be looking at the database, seeing a record that matches and assume that the program found data, but if something is formatted wrong in the actual SQL being executed, it did not actually return the results you expected.

If you have something misformatted (mismatching quotes, invalid characters in the variable 'inventory' that mess up the query, etc), echoing out the final sql statement and manually running it by hand is the best way to find out.

-Greg

[This space intentionally left blank]

Cool Geek Supplies: www.ThinkGeek.com

He has: 33 posts

Joined: Jun 2006

right here

"select email from newsletter where email =' & inventory & '"
you're missing quotation marks to separate the string from the variable

should be

"select email from newsletter where email ='" & inventory & "'"