473,568 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Prop erty'. 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.Descriptio n)

Err.Clear()

Resume Next

End If

*Waiting for Favourable reply, and Thanks in Advance

Jj........
Nov 21 '05 #1
5 8599
Please, use try/catch blocks!

"itsupport1 " <it**********@w ells.co.nz> wrote in message
news:uD******** ******@tk2msftn gp13.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_Prop erty'. 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.Descriptio n)

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**@removeeme rgencyreporting .com> wrote in message
news:uI******** ******@TK2MSFTN GP15.phx.gbl...
Please, use try/catch blocks!

"itsupport1 " <it**********@w ells.co.nz> wrote in message
news:uD******** ******@tk2msftn gp13.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_Prop erty'. 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.Descriptio n)

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**********@w ells.co.nz> wrote in message
news:#N******** ******@TK2MSFTN GP12.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**@removeeme rgencyreporting .com> wrote in message
news:uI******** ******@TK2MSFTN GP15.phx.gbl...
Please, use try/catch blocks!

"itsupport1 " <it**********@w ells.co.nz> wrote in message
news:uD******** ******@tk2msftn gp13.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_Prop erty'. 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.Descriptio n)

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**********@w ells.co.nz> wrote in message
news:%2******** ********@TK2MSF TNGP12.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**@removeeme rgencyreporting .com> wrote in message
news:uI******** ******@TK2MSFTN GP15.phx.gbl...
Please, use try/catch blocks!

"itsupport1 " <it**********@w ells.co.nz> wrote in message
news:uD******** ******@tk2msftn gp13.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_Prop erty'. 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.Descriptio n)

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**********@w ells.co.nz> wrote in message
news:uD******** ******@tk2msftn gp13.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_Prop erty'. 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.Descriptio n)

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
5182
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") '// This record does not exist thus throwing up an error. I could use On
3
3268
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 Without Add New or Edit. I understand that when trying to update records you have to work
13
6581
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
6818
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 GoTo HandleErr strBackupDir = "C:\BackupDir" On Error GoTo 0 ' isn't this supposed to turn off error trapping?
6
8444
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 by VisitDt" I'm getting this error message: Errno is 2465. Err.description is "Can't find field '|' referred to in your expression"
10
2273
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 written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on that ID, otherwise...
3
27403
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 message from Access. If I comment out the 1st On Error Resume Next and the x = 1 / 0 on the next line there is no difference, i.e. ther same unhandled...
4
3762
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 doesn't move to next element... this sad thing but, it's indication that we must move to try catch instead of on error.
11
47967
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
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7660
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.