Can SqlBulkCopy be used with a SQL Server Compact database?

sqlbulkcopy sql-server sql-server-ce

Question

I want to replicate a lot of data onto my live database utilizing (I have a local database and a live database.SqlClient to my own database (SqlServerCe database powered by SQL Server CE). How can I go about doing that?

1
0
10/27/2017 4:50:06 AM

Accepted Answer

Yes, you may use the SqlCeBulkCopy library/Nuget package I have:

https://github.com/ErikEJ/sqlcebulkcopy

Code example

using ErikEJ.SqlCe;

private static void DoBulkCopy(bool keepNulls, IDataReader reader)
{
    SqlCeBulkCopyOptions options = new SqlCeBulkCopyOptions();
    if (keepNulls)
    {
        options = options |= SqlCeBulkCopyOptions.KeepNulls;
    }
    using (SqlCeBulkCopy bc = new SqlCeBulkCopy(connectionString, options))
    {
        bc.DestinationTableName = "tblDoctor";
        bc.WriteToServer(reader);
    }
}
0
10/27/2017 5:45:11 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow