E
E. Kwong
I have a For loop to insert record to a SQL server database, like:
For Each item As ListItem In cblxyz.Items
If (item.Selected) Then
.... do something
Try
srcxyz.Insert()
Catch SQLExp As SqlException
....display error
End Try
End If
Next
Now when a duplicate record is encountered, it displays the error and then
stops. I need the loop to go on after displaying the database error. Is
there any way to do that? Or do I have to check whether the record is
already existing in the database every single time before doing the Insert?
Any insight appreciated.
I'm using VS2005, SQL Server 2000, .Net 2.0
For Each item As ListItem In cblxyz.Items
If (item.Selected) Then
.... do something
Try
srcxyz.Insert()
Catch SQLExp As SqlException
....display error
End Try
End If
Next
Now when a duplicate record is encountered, it displays the error and then
stops. I need the loop to go on after displaying the database error. Is
there any way to do that? Or do I have to check whether the record is
already existing in the database every single time before doing the Insert?
Any insight appreciated.
I'm using VS2005, SQL Server 2000, .Net 2.0