|
-
Jun 30th, 2005, 07:08 AM
#1
Thread Starter
Member
Ignoring ADO errors
What can I do to avoid the program stopping with an ADO error? It does not seem to be "trappeable"
Example:
objComm.CommandText = "INSERT INTO CorpExtractType (CorpCode, ExtractTypeID) VALUES ('" & sCorpCode & "'," & CStr(iExtractTypeID) & ")"
objComm.Execute()
This may fail due to a duplicate key for example, but I don't want to check for each command to see if the record already exist as it would slow things down. I just want to ignore any errors, but it won't play
Putting a try-catch arround it does not help as it bombs on the objcomm.Execute statement.
-
Jun 30th, 2005, 07:11 AM
#2
Re: Ignoring ADO errors
VB Code:
Try
objComm.CommandText = "INSERT INTO CorpExtractType (CorpCode, ExtractTypeID) VALUES ('" & sCorpCode & "'," & CStr(iExtractTypeID) & ")"
objComm.Execute()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
-
Jun 30th, 2005, 07:14 AM
#3
Thread Starter
Member
Re: Ignoring ADO errors
I have got a try - catch around it, but it bombs on the objcomm.execute statement, i.e. it does not get trapped.
-
Jun 30th, 2005, 07:18 AM
#4
Thread Starter
Member
Re: Ignoring ADO errors
This is the message I get first:
>>
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Harpo.exe
Additional information: The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
>>
And after that, it goes to the "catch" part
-
Jun 30th, 2005, 07:40 AM
#5
Re: Ignoring ADO errors
ComException? What exactly are you using in your project? What is objComm?
-
Jun 30th, 2005, 07:49 AM
#6
Thread Starter
Member
Re: Ignoring ADO errors
objComm = New ADODB.Command
These are ado commands.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|