The given ColumnMapping does not match up with any column in the source or destination.

549 views
Skip to first unread message

he...@uplevelapp.com

unread,
Dec 4, 2015, 2:23:22 PM12/4/15
to CSVChat
THe error I get is

"The given ColumnMapping does not match up with any column in the source or destination."

In my CSV is only eight columns.  The column heading is EXACTLY the same as my database column names.

In my SQL table, I have dozens more columns.

hereis my mapping...
bulkCopy.ColumnMappings.Add("locationID", "locationID")
bulkCopy.ColumnMappings.Add("timestamp", "timestamp")
bulkCopy.ColumnMappings.Add("dateEntered", "dateEntered")
bulkCopy.ColumnMappings.Add("contactType", "contactType")
bulkCopy.ColumnMappings.Add("firstName", "firstName")
bulkCopy.ColumnMappings.Add("country", "country")
bulkCopy.ColumnMappings.Add("emailAddress", "emailAddress")
bulkCopy.ColumnMappings.Add("marketingSourceDetail", "marketingSourceDetail")


Any ideas?


shriop

unread,
Dec 4, 2015, 2:39:04 PM12/4/15
to CSVChat
SqlBulkCopy's error messages suck, for lack of better words. That's why I made a wrapper that attempts to catch the mismatch before SqlBulkCopy and throws an appropriate error message, http://www.csvreader.com/posts/validating_datareader.php . I'm sure you made a mistake somewhere, capitalization, etc, but it's going to be something silly small. It should just take you a minute to wrap your code in ValidatingDataReader and it should immediately point you to the problem.

Bruce Dunwiddie
Reply all
Reply to author
Forward
0 new messages