Multiple bulk inserts with one SqlBulkCopy object

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top