faqts : Computers : Programming : Languages : Asp : ASP/VBScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 7 people (0%) answered Yes
Recently 0 of 7 people (0%) answered Yes

Entry

How can i check for a record already exists in the action page if my primary key is identity seed ?

Jun 8th, 2002 20:09
Wes DeMoney, Sumegha,


While this can be done easily by using a stored procedure, I will tell 
you how I do it using plain ol' ASP and whatever type of database 
(Access, MySQL, SQL Server). Basically what you want to do is, use the 
data that you just inserted as your WHERE clause, and SELECT your 
identity field.
Sample:
"INSERT INTO Contacts (CName, CEmail, CPhone) VALUES ('" & strName 
& "','" & strEmail & "','" & strPhone & "')"
Then:
"SELECT CID FROM Contacts WHERE (CName = '" & strName & "' AND CEmail 
= '" & strEmail & "')"
Now, this may be more load heavy on your DB query than a stored 
procedure, but it does the job when needed.



© 1999-2004 Synop Pty Ltd