Multiple bulk inserts with one SqlBulkCopy object

G

Guest

I have an app that generates a lot of data for multiple tables (on one
database). This seems perfect for the SqlBulkCopy object which, according to
the docs, can be used to handle this case as long as the properties on the
object are changed prior to each call to WriteToServer (DestinationTablename,
primarily).

The problem is, on the second attempt to use the one SqlBulkCopy object to
get data up into a table, the WriteToServer fails with an error about not
having a connection for the object.

What am I missing?

Thanks,
-- TB
 
G

Guest

Thomas W. Brown said:
I have an app that generates a lot of data for multiple tables (on one
database). This seems perfect for the SqlBulkCopy object which, according to
the docs, can be used to handle this case as long as the properties on the
object are changed prior to each call to WriteToServer (DestinationTablename,
primarily).

The problem is, on the second attempt to use the one SqlBulkCopy object to
get data up into a table, the WriteToServer fails with an error about not
having a connection for the object.

What am I missing?

Doh!!! Nevermind, I had a call to the SqlBulkCopy.Close() method tucked
away somewhere where I had overlooked it. This closed and null'ed out the
internal Connection object for the copier.

-- Tom
 

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