How to use SqlBulkCopy in C#?

 Posted by Vishalneeraj-24503 on 3/1/2015 | Category: Visual Studio Interview questions | Views: 448 | Points: 40
Answer:

Let's assume that,we have a datatable:-
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString, SqlBulkCopyOptions.KeepIdentity))

{
bulkCopy.DestinationTableName =
"your_table_name";
try
{
bulkCopy.WriteToServer(dt);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
}
}

Where,dt is our Datatable Object.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response