简体   繁体   中英

Copying Datatable to SQL Server CE table

I know this question was asked before but I have a little different requirement.

I need to copy data from SQL Server to a local application SQL Server CE file.

I got the table data from main server into a datatable, but I'm not able to efficiently copy that to SQL Server CE table.

I tried an adapter.update() but it takes a lot of time if number of rows are large (took around 3 min for 25k rows)

Inserted each datarow by calling insert command every time (highly inefficient and probably same as what adapter.update is doing)

I tried storing the values into a string and writing an insert command with that string so that I can insert 1000 rows each time I run the command. But it gives an error during parsing at the token ',' near second row value.

Exact error :

There was an error parsing the query. [ Token line number = 1,Token line offset = 40,Token in error = , ]

I tried SqlCeBulkCopy by erikej, it gives me an error sqlserverce.dll reference not found, I double checked I had the reference added and I have SQL Server CE 3.5 sp1 installed on the device.

Exact error :

Could not load file or assembly 'System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=3be235df1c8d2ad3, Retargetable=Yes' or one of its dependencies

Any directions on how I should proceed?

如果在设备上正确安装了3.5 SP2 cab文件,则可以使用SqlCeBulkCopy。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM