Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoiding adding duplicate info the your DB

Status
Not open for further replies.

timcadieux

Programmer
May 25, 2005
129
BE
Hi folkz, what's the smartest way of checking to see if a value exists in the DB, ignoring it if it exists or adding it if it doesn't?
 
If every value of the field should be unique then perhaps make it a key...Then you could just attempt to insert it and trap the key collision error when it is non-unique.

You could just query for it before running the insert but that will definately increase load on the db... sometimes this matters a lot more than others... if you have a big fancy dedicated database server that spends all day at 3% load then its not such a big deal...
 
I'd verify against the db see if the record exists:

"Select filedname from youTable where id = " & NewID

If rs.EOF then
'not exists, do the insert
Else
'exist
End if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top