473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

On Error Resume Next equllance in VB.NET?

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
5 8587
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: jason | last post by:
Is there a way to avoid On Error Resume Next for: cnn.Open strCon SQL = "EXEC Customer @txtEmail='" & email_address & "'" set rs = cnn.execute(SQL) 'On error resume next rs("email_address")...
3
by: Michael | last post by:
Hello again everyone, Hope you can help. I have a form with a lot of code going on in the background but I can't find the route cause of the following error message. Update or Cancel Update...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
2
by: deko | last post by:
I want to turn error handling off, then back on in a sub routine that backs up a select set of documents. For some reason, I can't seem to get this to work - Private Sub BackupDocs() On Error...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
3
by: bob.needler | last post by:
I know On Error Resume Next is generally considered lazy. But can someone tell me why the resume next in Exit_Handler does not seem to work? It generates the typical unhandled runtime error...
4
by: Neo | last post by:
I found on error resume next doesn't work in for each... e.g. on error resume next for each x in y 'do stuff next if you have an error in for each loop, it falls in infinite loop... it...
11
by: Maxwell2006 | last post by:
Hi, I know that this is not a good practice, but I wonder do we have "on error resume next" in C#? Thanks,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.