[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 730
  • Last Modified:

How to Sync data between Client(device) and Server Side

Dear all
I am new working with Windows mobile 6 and visual studio 2008
I want to know how I can make Sync between the Device and the SQL Server on the Server side.
Thanks,
0
RamzyNEbeid
Asked:
RamzyNEbeid
  • 24
  • 14
  • 4
  • +1
5 Solutions
 
Mikal613Commented:
You can use WCF, Web Services or remote sql.
0
 
RamzyNEbeidAuthor Commented:
can you give me an example of a full walk through

please

thanks
0
 
Mikal613Commented:
Remote SQL:

http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/bb135347-baee-4b60-b4a3-e5f4833d1ce4

Web Service:

Create a regular web service:
http://www.dreamincode.net/forums/topic/34279-introduction-to-web-services-in-c%23/

and just add the web reference to the Mobile project and you can use the methods from the web service.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
RamzyNEbeidAuthor Commented:
if i want to send the whole SDF to the webservice how can i do this ?

+ the example you provide me is not related to mobile devlopment.

i want to know what is the best way for doing this task.

thanks
0
 
RamzyNEbeidAuthor Commented:
what about Serialization form the device to the webservice
for both the SDF or XML.

thanks,
0
 
Mikal613Commented:
i believe that the SyncService  takes care of that.
0
 
RamzyNEbeidAuthor Commented:
my idea is to make a web service and send/receive all the data i want using Serialization between the server and the device.

is this ok or not ?
is it a good practice or not?
0
 
Mikal613Commented:
yes, serialization is good practice
0
 
RamzyNEbeidAuthor Commented:
can you tell me how to compress SDF and serialize it using C#
and send it to web service using C#?
0
 
Mikal613Commented:
dont think you want to do that.......

first look at the sync services

http://keithelder.net/2007/09/23/Sync-Services-for-SQL-Server-Compact-Edition-3.5-in-Visual/

If you dont like it, you would have to serialize all the tables of the database and then send it over.
0
 
Mikal613Commented:
actually you can create a dataset and do the following

System.Xml.Serialization.XmlSerializer serializer = new XmlSerializer( typeof( DataSet ) );
Stream stream = new FileStream( "Tables.xml", FileMode.CreateNew);
serializer.Serialize( stream, ds );
stream.Close();

and then send the file via byte array in the web services.
0
 
RamzyNEbeidAuthor Commented:
my idea is ti ZIP the database and serialize it and send to the web service and the Web Service will do the job needed.

tell me what do you think?
0
 
Mikal613Commented:
well you can select all the data into a dataset and serialize it into a xml file, zip and send via web service.
0
 
RamzyNEbeidAuthor Commented:
i need your help

i create a SDF and i wrote a code to select from this SDF and bind to a datagrid

and i make an another code for the Insert then everyting is ok

it saves data in the SDF and i can see this data from the Query analyzer inside the emulator.

but when i stop the emulator i cant find the data i inserted in the SDF in my project ?
0
 
Mikal613Commented:
" stop the emulator" ???

If you close the emulator without saving the state of the emulator, all data will be lost.
0
 
RamzyNEbeidAuthor Commented:
The only problem is that the database within the emulator gets updated but not the one on the pc(within server explorer). Any ideas??

tell me what to do ?
0
 
RamzyNEbeidAuthor Commented:
" stop the emulator" ??? then how can i test the mobile application ?
0
 
Mikal613Commented:
"The only problem is that the database within the emulator gets updated but not the one on the pc(within server explorer). Any ideas??"

Are you sure the emulator has an internet connection?
0
 
RamzyNEbeidAuthor Commented:
how to know this? and if yes what is your point?
0
 
Mikal613Commented:
how to know this?

can you goto google from ie on your emulator?

and if yes what is your point????

ummmm how do you expect the data to go from your emulator to the server????
0
 
RamzyNEbeidAuthor Commented:
i am new to this subject so that why i am asking ?

i dont know and if there is any thing better than the emulator

i have deveice can i use it better "MC70 & MC75"?
0
 
RamzyNEbeidAuthor Commented:
no it is not connected to Internet
0
 
Mikal613Commented:
MC70 or MC75 no difference if they are both running windows mobile.
0
 
RamzyNEbeidAuthor Commented:
i mean they will act for me as real testing and saves the data and i can debug everything ?
0
 
Mikal613Commented:
yup!!! its actually better!!
0
 
RamzyNEbeidAuthor Commented:
Thanks
0
 
cubaman_24Commented:
Hello:
You should take a look at Sync Framework..
http://msdn.microsoft.com/en-en/library/bb902854.aspx
0
 
RamzyNEbeidAuthor Commented:
Something else i want to tell you i have another application runnig on the same device with its SDF database
I want form my application to connect to this database and select data from it.
At the same time the a
Other application is using this SDF

Please advice
0
 
RamzyNEbeidAuthor Commented:
Please tell me
0
 
Mikal613Commented:
Dim MyConnection As SqlCeConnection

Dim datalocation As String = "\Program Files\OtherApplication\YourDatabase.sdf"

MyConnection = New SqlCeConnection("Data Source=" & datalocation)
0
 
hjgodeCommented:
Hello

I dont know why you want to re-invent the wheel.

There is a MS solution called SQL RDA and it is described with working example in Pauls Yao's book "Programming the compact framework" (VB or C# edition): https://www.google.com/search?q=paul+yao+compact+framework#q=paul%20yao%20compact%20framework&um=1&ie=UTF-8&hl=en&tbo=u&tbm=bks&source=og&sa=N&tab=wp&psj=1&ei=eFFdUPajGcXTtAaz2YCQDA&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=a8518f6df571a1a4&biw=1023&bih=496

The SQL server and the SQLCe only sync changed data automatically on request on the mobile code.

~josef
0
 
RamzyNEbeidAuthor Commented:
i did deploy my application on the device with Compact Framework 3.5

when i try to connect to another application SDF i got this error:
{The database file has been created by an earlier version of SQL Server Compact. Please upgrade using SqlCeEngine.Upgrade() method.}

i fogiure out later the this application is running under Compact Framework 2.0

so how can i connect from my application 3.5 on the SDF 2.0 just to read data?

thanks,
0
 
RamzyNEbeidAuthor Commented:
i was able to fix the problem by using the dll System.Data.SqlServerCe of Compact 2.0

now i want to add refrence to my application (in the same application):
System.Data.SqlServerCe  2.0
System.Data.SqlServerCe 3.5

how can i do this ?
0
 
RamzyNEbeidAuthor Commented:
please i need your help.

thanks,
0
 
hjgodeCommented:
Hi

you may reference multiple assemblies of same class using an alias. Here is an example http://geekswithblogs.net/narent/archive/2008/11/11/126940.aspx

Further on, I would write wrapper libs to access the one or other. I assume best would be to create two class library projects implementing the same data access interfaces, one using SqlCE 2.0 and the other using SqlCe 3.5. Then in your main project you may use the one or other library.

Why cant you upgrade the 2.0 sdf file?

Do you really need to use SQLCe 3.5 and a CF 3.5 app? You can also write a SQLCe 2.0 / CF 2.0 application. Or do you need any of the CF3.5 enhancements?
0
 
RamzyNEbeidAuthor Commented:
i want to work using VS2008 with SQLCE2.0 but i wasnt able to do this ?
0
 
RamzyNEbeidAuthor Commented:
the solution you gaved me for the "multiple assemblies of same class " is not working
0
 
hjgodeCommented:
Are you kidding?

If you have installed Compact Framework 2, you can decide to use CF2 or CF 3.5 in a new SmartDevice .Net project.

The attached VS2008 project uses SQLCE2.0 files within a CF2 application targeted at WM5.

Running SQLCE2 in CF2 on WM5
extern alias SQLCE2;
extern alias CF2;
//the above allows us to use different versions of the same assembly

//for autodeploy copy 
//  C:\Program Files (x86)\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile
//to
//  C:\Program Files (x86)\Microsoft Visual Studio 9.0\SmartDevices\SDK\SQL Server\Mobile
using System;

using System.Collections.Generic;
using System.ComponentModel;

//using System.Data;

using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.IO;

//example by http://msdn.microsoft.com/en-us/library/aa226134%28v=sql.80%29.aspx
//##############################################################################
//from special dir:
// C:\Program Files (x86)\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v2.0\...

...
                cmd.Parameters.Add(new SqlCeParameter("p1", SQLCE2.System.Data.SqlDbType.Int));
                cmd.Parameters.Add(new SqlCeParameter("p2", SQLCE2.System.Data.SqlDbType.NText));
                cmd.Parameters.Add(new SqlCeParameter("p3", SQLCE2.System.Data.SqlDbType.Money));
...

Open in new window

SqlCe2test.zip
0
 
RamzyNEbeidAuthor Commented:
i am using this DLL Symbol.Fusion.dll to connect to WLAN dll version is 2.6.0.3

and i am facing this error: "No compatible FusionInterface dll found. Expected version is 4.3.0.2 or higher version having the format 4.x.x.x"

please i need your advice it is so urgent.

 - i want to Enable/Disable WLAN
 - i want to Connect to specific access Point

thanks,
0
 
RamzyNEbeidAuthor Commented:
sorry my device is MC70 & MC75 windows mobile 6 & 6.5
0
 
hjgodeCommented:
I assume you should open another question thread for your Symbol Fusion problem.

What is about the SQLCE answer I gave?
0
 
RamzyNEbeidAuthor Commented:
sure i will

and yes it is working.

thanks,
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 24
  • 14
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now