By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,039 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,039 IT Pros & Developers. It's quick & easy.

On Error Resume Next equllance in VB.NET?

P: n/a
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........
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Please, use try/catch blocks!

"itsupport1" <it**********@wells.co.nz> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
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........

Nov 21 '05 #2

P: n/a
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
"Jeff Dillon" <je**@removeemergencyreporting.com> wrote in message
news:uI**************@TK2MSFTNGP15.phx.gbl...
Please, use try/catch blocks!

"itsupport1" <it**********@wells.co.nz> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
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........


Nov 21 '05 #3

P: n/a
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

"itsupport1" <it**********@wells.co.nz> wrote in message
news:#N**************@TK2MSFTNGP12.phx.gbl...
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
"Jeff Dillon" <je**@removeemergencyreporting.com> wrote in message
news:uI**************@TK2MSFTNGP15.phx.gbl...
Please, use try/catch blocks!

"itsupport1" <it**********@wells.co.nz> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
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........



Nov 21 '05 #4

P: n/a
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

"itsupport1" <it**********@wells.co.nz> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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
"Jeff Dillon" <je**@removeemergencyreporting.com> wrote in message
news:uI**************@TK2MSFTNGP15.phx.gbl...
Please, use try/catch blocks!

"itsupport1" <it**********@wells.co.nz> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
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........



Nov 21 '05 #5

P: n/a
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.

"itsupport1" <it**********@wells.co.nz> wrote in message
news:uD**************@tk2msftngp13.phx.gbl...
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........

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.