check to see if record exists ... prob
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 posted this at 06:02 — 6th June 2006.
He has: 2,145 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
adjroth posted this at 07:12 — 6th June 2006.
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 & "'"
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.