To contact us Click HERE
The below method is used to bulk insert in to a table by using c# from a datatable.
using System.Data;
using System.Data.SqlClient;
public int BulkInsert(DataTable dt, string TableName, string ConnectionString)
{
int returnValue = -1;
SqlConnection oConn = new SqlConnection(ConnectionString);
oConn.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM " + TableName,oConn);
da.SelectCommand.Connection = oConn;
DataSet ds = new DataSet();
SqlCommandBuilder oCmd = new SqlCommandBuilder(da);
try
{
da.Fill(ds);
returnValue = da.Update(dt);
}
catch (Exception ex)
{
throw ex;
}
finally
{
oConn.Close();
oCmd.Dispose();
}
return returnValue;
}
...S.VinothkumaR.
Hiç yorum yok:
Yorum Gönder