By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,166 Members | 1,323 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,166 IT Pros & Developers. It's quick & easy.

Transfer dataset from server to client and keep in sync

P: n/a
Hi,

my server has a database table. I read this table on the server into a
dataset and my client retrieves it through a webservice.

No changes on the client and server happen. What's the best way to keep the
data in sync?

I want to avoid that I transfer the entire dataset all the time. Is there a
way just to send/receive the changes?

Thanks for any hint

Anthony
--
Anthony Malt
Jan 3 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Anthony

One thing you can look at is the getchanges method of your dataset. You
can use it to perform the following steps

1) Retrieve the dataset from the server
2) The client modifies the dataset
3) The client submits only the changed rows
4) The server merges the changed rows into its dataset
5) The server accepts the new changes on the dataset

Here is some sample code that would do this.

//retrieve the dataset from your service
Dim dsClientSide As DataSet = YourWebService.GetData()

//Modify the ds
ModifyDataSetContents(dsMain)

//Send back the changes
Dim dsModifiedRows As DataSet = dsClientSide.GetChanges()
objWebService.SubmitChanges(dsModifiedRows)

//Back in the service, merge the recieved changes back into the
server's own copy of the ds
dsServerSide.Merge(dsChanges)
dsServerSide.AcceptChanges()

Note, in order for the merge method to work, your dataset needs to have
a PrimaryKey property set.

Hope that helps

Peter Kelcey

Jan 4 '06 #2

P: n/a
Hi Peter,

thanks for your answer. Actually I need the other way around. The client
does not modify the dataset. I would like just to subscribe to the changes,
which come from the server.

So the client stores the cache (store dataset as xml) and is disconnected
for long time. I would like to load the cache on the client and just
received the changes from the server.

Any thought?

Thanks in advance
Anthony

--
Anthony Malt
"Peter Kelcey" <Pe**********@telus.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Anthony

One thing you can look at is the getchanges method of your dataset. You
can use it to perform the following steps

1) Retrieve the dataset from the server
2) The client modifies the dataset
3) The client submits only the changed rows
4) The server merges the changed rows into its dataset
5) The server accepts the new changes on the dataset

Here is some sample code that would do this.

//retrieve the dataset from your service
Dim dsClientSide As DataSet = YourWebService.GetData()

//Modify the ds
ModifyDataSetContents(dsMain)

//Send back the changes
Dim dsModifiedRows As DataSet = dsClientSide.GetChanges()
objWebService.SubmitChanges(dsModifiedRows)

//Back in the service, merge the recieved changes back into the
server's own copy of the ds
dsServerSide.Merge(dsChanges)
dsServerSide.AcceptChanges()

Note, in order for the merge method to work, your dataset needs to have
a PrimaryKey property set.

Hope that helps

Peter Kelcey

Jan 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.