Import Bulk Data to SQL Server Using SqlBulkCopy
using System;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data.SqlClient;
Public class bulkcopyTest
{
Public void bulkcopyTestEG(DataTable dtEmport)
{
try
{
OleDbConnection Con = CreateConnection("Connection_String");
//Open bulkcopy connection.
using (SqlBulkCopy bulkcopy = new SqlBulkCopy(Con))
{
//Set destination table name
//to table previously created.
bulkcopy.DestinationTableName = "Bulk_Copy_Test";
try
{
bulkcopy.WriteToServer(dtEmport);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment