I am using SqlBulkCopy. So I made a datatable and specifed it’s columns then added rows to the datatable and then try to insert it.
System.InvalidOperationException was
unhandled by user code Message=The
given value of type String from the
data source cannot be converted to
type int of the specified target
I keep getting this error though. The thing is I have 3 int columns and I have no clue which one it is.
I even put on each int column the type of of it.
datatable.Columns.Add("Id", typeof(int));
Still seems to have problems. So where in the stack trace or int the exception will it say the actual column it dies on?
Check out Bruce Dunwiddie’s excellent ValidatingDataReader class. It provides really excellent information in the exception messages when you have this kind of mapping issue.