ExecuteNonQuery with error checking (or continue on error equiv)

G

Guest

First off I'll explain why I need something similar to ContinueUpdateOnError
feature that a data adapter has, and why I can't just use a data adapter.
Basically I'm updating a Large amount of data using BCP to copy the data to a
temp table in order to quickly move the mass amount of data from a flat file
to my database. I Then run updates on the temp table I just loaded that
insert AND update the data from the temp table to the production table. The
reason i do this is because my data (unfortunately) contains both inserts and
updates. The most efficient way I've found to do this involves using BCP to
move the data, then running SQL Statements I have generated to process the
updates and inserts from the temp table to the production table in the
database. I'm using something 'similar' to the BCP code from the PDC 05
Demo's ( http://blogs.msdn.com/dataaccess/archive/2006/01/09/510083.aspx )
Well it appears that when using try/catch if I have errors that yes it will
catch the error, however I have no control over it. The entire Update
command will then hault not updating any records. Is there some way to have
the ability to continue on with my SQL statement if it happens to hit a
record that doesn't have a corresponding foreign key or something similar?
Thanks
 
G

Guest

Still nothing? Point me in the right direction. Give me a better way to
solve my problem. All advice welcome
 
S

Sanjib Biswas

Only thing you could do in this scenario, is to continue executing next sql
statement. You should declare the OleDbCommand variable outside the try
block and also you have to keep a track of what sql command you are
executing.
 

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

Top