I have below data table :-
I have below SQL table as Product
:
ITEM CODE from data table is ProductCode
in SQL.
CLOSING (Last column in image) from data table is Quantity
in SQL.
I wanted to update ITEM CODE against CLOSING (Quantity) in SQL.
I wrote this bulk update function:
using (SqlBulkCopy bcSQL = new SqlBulkCopy(con))
{
bcSQL.DestinationTableName = "Product";
// Map Source column name to Destination Column name
// Src Column is in your DataTable
// Dest Column is column name available in your SQL Table
bcSQL.ColumnMappings.Add(" ITEM CODE", "ProductCode");
bcSQL.ColumnMappings.Add(" Closing", "Quantity");
bcSQL.WriteToServer(dt);
}
But I get this error:
The given ColumnName ' ITEM CODE' does not match up with any column in data source.
Please help - how can I resolve this?