On Error Resume Next equllance in VB.NET?

  • Thread starter Thread starter itsupport1
  • Start date Start date
I

itsupport1

Hi,

I am importing some records from one table to another table, and due to
Constraints in the destination table, it Throws an Exception and Skip the
Whole Rest of records.

So I did implement the On Error Resume next Statement, to avoid skipping the
process of Inserting the records.
But the Problem is

I have only 10 Rows in Source table and 100 rows in Destination table, But
it through Exception Like This.

11/3/2004 8:57:42 AM The server threw an exception.
11/3/2004 8:57:42 AM INSERT statement conflicted with TABLE FOREIGN KEY
constraint 'FK_Result_Property'. The conflict occurred in database
'dmyData', table Property'.
The statement has been terminated.

This statement appeared more than 40 times , why it is logging it more than
40 times, as I have only Ten rows to Verify?

Here is my Error Trapping procedure

errr:

If Err.Number <> 0 Then

Call WritetoTextFile(Err.Description)

Err.Clear()

Resume Next

End If



*Waiting for Favourable reply, and Thanks in Advance

Jj........
 
I tried to Use the Try and Catch Block.
But the problem is When Any exception is occurred then I want to transfer
the control to the very next Statement in Try Block? just like that One
error resume next do.

So how I am going to do that??

TIA
 
Fix the errors then. Make sure in your query logic that you don't update
incorrectly.

Simply ignoring errors and going forward is bad practice.

Jeff
 
You can do that with Try, Catch , Finally. Do a Google search and you will
find tons of posts explaining how to use it.
Try
<do something>
Catch
<catch exception and display results>
Finally
<the code you want to execute>
End Try

This works as long as the code in your Finally portion does not throw an
error too. As I said, search for Try, Catch, Finally and you will find a lot
of posts talking about this and different ways to use it. Including Nexted
Try , Catch blocks.
One thing I found out early on, you cannot use a Try , Catch, Finally, End
Try block in the same sub as you have an : On Error Resume Next statement.
I tried it and got errors real fast.
james
 
First, the "On Error Resume Next" statement doesn't work with ADO, even in
VB6. Second, you really need to find the error and fix it. Do this by
single stepping through your code to find the exact line that fails. Then
figure out why the failure is occurring.

Mike.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

resume next in VB.NET ? 10
Excel On Error Resume Next 2
On Error Resume Next 25
Resuming from an error 5
On error resume next bug 4
errorhandling with resume next... 2
On error resume next not working 3
Replacement for Resume Next 7

Back
Top