I am using VS 2008 with SQL Server 2005 and SQL Server Compact Framework 3.5
- I have mobile devices(They have Window Ce 6.0 os).
- I installed my program to windows ce devices
I am using .sdf database in device.
.SDF
and.MDF
database schema are the same
Workers use this devices out of company and save data.
When they arrive at the company I have to save the data from their .sdf
files into a SQL Server instance.
I do it like this:
public void TransferData()
{
SqlCeCommand tempcecommand=new SqlCeCommand("select * from Customer",SDFConnection);
SqlCeDataReader tempcereader=tempcecommand.ExecuteReader();
SqlCommand tempmscommad=new SqlCommand("",MDFConnection);
while(tempcereader.Read())
{
tempcommandtext = String.Format("insert into Customer (Column1,Column2) values ('{0}','{1}')",tempcereader["Column1"],tempcereader["Column2"] ;
tempmscommand.CommandText = tempmscommand;
tempmscommand.ExecuteNonQuery();
}
}
Is there an easier way to transfer the data from the .sdf
file into the SQL Server instance?