copy table from sdf file to another sdf file

V

Viki

Hi,

I have a question. I have 2 SDF files on WINCE-machine. How can I copy 1
table from first SDF-file to second SDF-file?

I want to make SDF-file on PC and to change original SDF-file on WINCE by
force of this SDF-file. I want to use it, because I have 70000 records in
table and it takes 20 minutes to insert to SDF-file. I need to be completed
to 2-3 min.

Thanks,

Viki
 
W

W.G. Ryan - MVP

Viki:

You can fill a datatable with an Adapter setting its AcceptChangesDuringFill
property to false. Then configure an adapter to point to the second table,
and passing in the same datatable, call Update.
 
V

Viki

Hi,

I tried it, but I don't know, how to change DataAdapter to second SDF. Can
you help me?
Here is my test.

Thank you

Viki

Private Sub CopyTable()
Const file_sdf_1 As String = "\first.sdf"
Const file_sdf_2 As String = "\second.sdf"
Dim conn_1 As SqlServerCe.SqlCeConnection = Nothing
Dim conn_2 As SqlServerCe.SqlCeConnection = Nothing
conn_1 = New SqlServerCe.SqlCeConnection("Data Source = " & file_sdf_1)
Try
conn_1.Open()
Catch
Return
End Try
conn_2 = New SqlServerCe.SqlCeConnection("Data Source = " & file_sdf_2)
Try
conn_2.Open()
Catch
Return
End Try
Dim dt As New DataTable
Dim err As Int16 = 0
Dim da As New SqlServerCe.SqlCeDataAdapter("SELECT * FROM centr_skl",
conn_1)
da.AcceptChangesDuringFill = False
Try
da.Fill(dt)
Catch ex As Exception
err = 1
End Try
'????? change - Connection ->conn_2
If err = 0 Then
Try
da.Update(dt)
Catch ex As Exception
err = 2
End Try
End If
conn_1.Close()
conn_2.Close()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top