I have a data table .I want to push it to the sql table using Sqlbulkcopy .
- Data table dt=new datatable();some data were loaded
- Push this data to sql table.
- string connectionstring = @"Data Source";
- using (SqlConnection destinationConnection = new SqlConnection(connectionstring))
- {
- destinationConnection.Open();
- using (SqlBulkCopy bulkCopy =new SqlBulkCopy(destinationConnection.ConnectionString)) {
- bulkCopy.DestinationTableName = "studentmanagement";
- bulkCopy.ColumnMappings.Add("Name", "Name");
- bulkCopy.ColumnMappings.Add("Subjectname", "Subjectname");
- bulkCopy.ColumnMappings.Add("Marks", "Marks");
- bulkCopy.WriteToServer(dt);
- }
- destinationConnection.Close();
- }
Error populating Cannot access the destination table.
Its not working.please anyone help me to solve this?



Nitin SontakkeRank #264 · 9.6K reputationPosted Jan 29, 2017, 11:13 PM EST
Amit KumarRank #459 · 5.4K reputationPosted Jan 30, 2017, 1:47 AM EST
Saber ShaikhRank #1,687 · 905 reputationPosted Jan 29, 2017, 9:38 PM EST
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Jan 29, 2017, 9:43 PM EST
Nitin SontakkeRank #264 · 9.6K reputationPosted Jan 29, 2017, 10:51 PM EST
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Jan 29, 2017, 10:57 PM EST
Nitin Sontakke