SqlBulkCopy
Posted: Mon 05 Sep 2011 11:58
I have problem with SqlBulkCopy class. Here is code sample:
If I use Devart component SqlBulkCopy opens new connection (different SPID in Sql Server Profiler) and executes "INSERT BULK", while System.Data.SqlClient.SqlBulkCopy uses the same connection. It is a problem because I cannot do SqlBulkCopy into local temporary table and use that table somwhere else in application.
There is a second problem. If I want this procedure to work Devart.Data.SqlServer.SqlConnection ConnectionString must have: "Integrated Security=True" while System.Data.SqlClient.SqlConnection does not require that flag.
Is there some solution of my problem?
Components:
Devart.Data.SqlServer version 2.40.307.0
Code: Select all
public static void ExportToTableDevart(Devart.Data.SqlServer.SqlConnection connection, string tableName, DataTable dataTable)
{
// create table
Devart.Data.SqlServer.SqlBulkCopy bcp = new Devart.Data.SqlServer.SqlBulkCopy(connection);
bcp.DestinationTableName = tableName;
bcp.WriteToServer(dataTable);
}
public static void ExportToTable(System.Data.SqlClient.SqlConnection connection, string tableName, DataTable dataTable)
{
// create table
System.Data.SqlClient.SqlBulkCopy bcp = new Devart.Data.SqlServer.SqlBulkCopy(connection);
bcp.DestinationTableName = tableName;
bcp.WriteToServer(dataTable);
}
There is a second problem. If I want this procedure to work Devart.Data.SqlServer.SqlConnection ConnectionString must have: "Integrated Security=True" while System.Data.SqlClient.SqlConnection does not require that flag.
Is there some solution of my problem?
Components:
Devart.Data.SqlServer version 2.40.307.0