I'd suggest to use
SqlCeBulkCopy class[
^] (from codeplex), which provides several options to copy data between databases in a safe way.
How to use it?
1) download and install
this nuget packet[
^],
2) create new project,
3) create new
OleDbConnection[
^] to load data from Excel into
DataTable[
^] object (using
OleDbCommand[
^] +
OleDbDataReader[
^]),
4) close OleDbConnection (do NOT delete
DataTable
object, you'll use it in the next step!),
5) create new
SqlCeConnection[
^],
6) create new
SqlCeBulkCopy
class and use
WriteToServer
method. Pass
DataTable
object as an input parameter,
7) close
SqlCeConnection
.
That's all!
For further details, please download the
documentation[
^].