how to SqlBulkCopy using different column between excel and dabase table

Last Reply on Mar 17, 2016 07:33 AM By Shashikant

Posted on Mar 16, 2016 04:24 AM

Can anyone tell me how to add data using excel data with 3 columns into database table that has 9 columns.

I'm using this tutorial to bulk my data.

FYI: I'm totally newbie

Thanks & Regards

Posted on Mar 16, 2016 04:25 AM


You need to map the Column name link below as Given in article

sqlBulkCopy.ColumnMappings.Add("Id", "PersonId")
sqlBulkCopy.ColumnMappings.Add("Name", "Name")
sqlBulkCopy.ColumnMappings.Add("Salary", "Salary")

I hope this will help you out.

Posted on Mar 17, 2016 07:22 AM

I found the issue, it seems that I misstype the column name.


@Shshikant: thanks for your attantion and help :)