Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
9
Reply
Bulk copy in Sql using C#
Dinesh Santhalingam
Jan 30 2017 1:16 AM
347
Reply
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?
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
9
)
Next Recommended Forum
How to integrate Aadhaar card with C# (VS 2012-2013)?
real time example