This topic is locked

Checking to see if Record exists

1/22/2008 3:24:35 PM
ASPRunnerPro General questions
M
MikeGinMN author

I have a table called Web-Registration-Athletics which has the primary key as StateID. I want to check to see if a new addition StateID is in table - if it is I would like to display a message and not add record
Here is what I have
strSQLExists = "select from "dbo.Web-Registration-Athletics" where StateID='dict(StateID)'"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
if not rsExists.eof then

' if record exists do something

Response.Write "<script>alert('Person is already registered into these games')</script>"

else

' if dont exist do something else
end if

rsExists.Close : set rsExists = Nothing
but I get this when I go to web page
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/SOMNAreas/state/athletics/include/Web_Registration_Athletics_events.asp, line 85
strSQLExists = "select
from "dbo.Web-Registration-Athletics" where StateID='dict(StateID)'"
-----------------------------------^
Note sure what I am doing wrong - any help would be greatly appreciated

S
stealthwifi 1/23/2008

Change your strSQLExists to this - it should fix it.
[codebox]strSQLExists = "select * from dbo.Web-Registration-Athletics where StateID='dict(StateID)'"[/codebox]
Stealth-

M
MikeGinMN author 2/11/2008

Thank you

Sergey Kornilov admin 2/12/2008

Here is correct one:

strSQLExists = "select * from dbo.Web-Registration-Athletics where StateID='" & dict(StateID) & "'"