DBNull with SQLBulkCopy

D

dwelzel

While using SqlBulkCopy to load data into a SQL Server 2005 database,
I've noticed an occasional exception that is saying one of the fields
in my DataTable object contains a null value and this is failing the
not null constraint on the table.

When I set up the DataTable object prior to the bulk insert I simply
set this field to an integer value, so it is never null in my code.
I've even put in some validation code on the DataTable object that runs
prior to the bulk insert and everything looks like.

This is a sporadic error and I've seen a few others that are similar so
it worries me that the objects are getting (slightly) corrupted between
the time I build them and when the bulk insert actually happens.

Has anyone seen something similar to this?

Thanks!
 

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