Tag Archives: database

SqlBulkCopy Matching Columns

If you’re trying to do a SqlBulkCopy using a DataTable and getting lots of column type (integer, string) mismatches, it’s probably because you haven’t mapped not only the column types, but also the column names.

SqlBulkCopy assumes that your DataTable is going to have its columns in the same order as the database table, which will cause mismatches when it tries to send your (string) Name field into your (int) Age column.

Just having your DataTable column names match the table isn’t enough, either. There must be a manual mapping.

But if your DataTable column names are the same as the table column names, a simple method can take care of that mapping for any DataTable you send it.

Continue reading SqlBulkCopy Matching Columns

Weekly linkage

Down to six hundred sixteen unread Google Reader items! Here are some of the coolest of the nearly 200 I’ve read in the last couple of weeks (as well as random surfing, of course):

Quasi-daily linkage

Quasi-daily linkage

Quasi-daily linkage