Following C# syntax can be used for multiple insertion using sqlbulk:
SqlBulkCopy bulkcpy = new SqlBulkCopy(con);
bulkcpy.ColumnMappings.Add("columnname1", "datasetcolumn_Name1");
bulkcpy.ColumnMappings.Add("columnname2", "datasetcolumn_Name2");
bulkcpy.ColumnMappings.Add("columnname3", "datasetcolumn_Name3");
bulkcpy.ColumnMappings.Add("columnname4", "datasetcolumn_Name4");
bulkcpy.ColumnMappings.Add("columnname5", "datasetcolumn_Name5");
bulkcpy.ColumnMappings.Add("columnname6", "datasetcolumn_Name6");
bulkcpy.DestinationTableName = "Database_TableName";
bulkcpy.WriteToServer(DataTable);
Happy Coding !! :)
SqlBulkCopy bulkcpy = new SqlBulkCopy(con);
bulkcpy.ColumnMappings.Add("columnname1", "datasetcolumn_Name1");
bulkcpy.ColumnMappings.Add("columnname2", "datasetcolumn_Name2");
bulkcpy.ColumnMappings.Add("columnname3", "datasetcolumn_Name3");
bulkcpy.ColumnMappings.Add("columnname4", "datasetcolumn_Name4");
bulkcpy.ColumnMappings.Add("columnname5", "datasetcolumn_Name5");
bulkcpy.ColumnMappings.Add("columnname6", "datasetcolumn_Name6");
bulkcpy.DestinationTableName = "Database_TableName";
bulkcpy.WriteToServer(DataTable);
Happy Coding !! :)
No comments:
Post a Comment