how to add column mapping in sqlbulkcopy in c# where column names contains White Space

佐手、 提交于 2019-12-11 13:32:42

问题


using (SqlBulkCopy sc = new SqlBulkCopy(conn))
{
    sc.DestinationTableName = destination;

    sc.ColumnMappings.Add("ID","ID #");
    sc.ColumnMappings.Add("Amount","Amount in USD");

    sc.WriteToServer(datatable);
}

I am getting error that column dose not match in given columnmapping

Thanks in Advance.


回答1:


found solution need to add Square brackets around the fields only where the White space involved in column name



来源:https://stackoverflow.com/questions/23335920/how-to-add-column-mapping-in-sqlbulkcopy-in-c-sharp-where-column-names-contains

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!