vaj said:
Hey,
Im creating a system on a pocket pc based on win ce 4.2 and i need to
tranfer three datasets to a remote server on the network.Could anyone
tell me the easiest way to do this?
cheers,
-vaj
Here's a solution that I'm trying to get working on one of my own
projects. It pretty much works, although I don't know if it's a best
practice or anything...(Maybe some others can weigh in on the overall
approach.)
I'm not sure what the .NET framework looks like on WinCE, but in the
full .NET framework, you can get a dataset containing just
updated/changed data with something like:
dsModified = dsModified.GetChanges()
See the docs on .GetChanges for a fuller explanation of some options
there.
Then you take that dataset and pass it to a web service, which has a
web method that accepts a dataset as a parameter, and merges it with a
dataset containing the latest data from the server (da = data adapter,
ds = dataset):
sql = "SELECT NameFirst, NameLast FROM tblContacts"
cn = DBConnect()
cn.Open()
daOriginal = New SqlDataAdapter(sql, cn)
daOriginal.Fill(dsOriginal)
dsOriginal.Merge(dsModified)
Then you write the data to the database:
daOriginal.UpdateCommand = cmd.GetUpdateCommand()
daOriginal.Update(dsOriginal)
We've had to do some other things like explicitly setting the primary
key on dsModified to match the pkey on dsOriginal, but that might be
due to some conversions to and from XML and old-style ADO recordsets we
do between the various layers of the app.
If nothing merges in, it may be because the rowstate of the dateset
rows have been set back to "unchanged" as it came into the web service.
In ADO.NET 2.0, you can apparently manually set the rowstate of the
rows.
The MSDN on .Merge is pretty helpful, although it doesn't seem to
recommend using Merge for this purpose.