Thread: Insert issue?
View Single Post
  #2 (permalink)  
Old June 14th, 2005, 04:00 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 33,170, Level: 79
Points: 33,170, Level: 79 Points: 33,170, Level: 79 Points: 33,170, Level: 79
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,161
Thanks: 7
Thanked 188 Times in 186 Posts
Default

You could fire an additional SELECT query to see if the item exists before you insert it.

Something along these lines would work:
Code:
Dim rsCheck
Set rsCheck = myConnection.Execute("SELECT 1 FROM MyTable WHERE Column1 = 'SomeValue' AND Column2 = 'SomeOtherValue'")
If rsCheck.EOF Then
  ' Record does no exist, so go ahead and insert a new one
Else
  ' Do whatever you need to do when the record exists
End If
rsCheck.EOF
Set rsCheck = Nothing
Does this help??

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Butterflies & Hurricanes by Muse (Track 10 from the album: Absolution) What's This?
Reply With Quote