October 2nd, 2003, 02:51 AM
DataSet and Moving Data
I have two databases, one at the client side and the other at the server(Access Database), the client side is a desktop application which updates the client side DB and the server side is a web service which updates the server DB. I would like to make all changes to the database through the client side and then submit all changes at one time to the server side.
The solution I use depends on the Datasets, I create two datasets one on the client and the other on the server and then get the changes for the one on the client side and merge it with the one on the server and use the update command to do the updates for the server side DB. This solution works very fine for the Update and Delete commands however it doesn't work with the Insert command ( It says error in the INSERT INTO Statement)
1-The DataAdapter on the server side uses the command builder to build the Insert, Delete and Update commans.
2-The two Select statements are the same (Client and Server).
3-The two databases have the same shema and Data.
October 2nd, 2003, 11:55 AM
I can help you here!
ok, I'd actually like to wrap my mind around your mindset as well....
so you have a clientside DB and a serverside DB. When you post changes to the clientside DB, you want the same changes to go to the serverside DB.
- i'm guessing you have some shoppingcart program or something where you have them maintain the data on the client side and post the changes to the server for a website.
? The first question I have (just trying to help here) is why have the entire database in two locations? Why not just have the app speak to the webservice and go from there? = or is it that some other program keeps track of the DB and then you just read the changes and post them to the website? (I'm going to assume this scenario)
= The reason you insert statement is not working is because you are not really INSERTING data (it sounds like). When you copy the data from on adapter/dataset and put it in another, you never set the ADD key the adapter is looking for in the dataset's METADATA. So it just sees mismatched data.
1. If you have the app that is adding the line to the DATASET:
2. If you are not the authority, and only find the additions:
== What you really need to do is read the data from the client side DB into a dataset (DS1), and read the serverside DB into a DataSet (DS2) right from the start.
(1) if you are adding the row to the client (DS1), then you must do the very same command to add the row to the server (DS2). This add command triggers the input of a ADD key into the METADATA which the datasource can read and understand.
(2) If you are only REACTING to an addition that is FOUND, then you must (NOT COPY DATA FROM ONE TO THE OTHER AND HIT UPDATE!) you must compare the two groups of data, and isolate the NEW row(s) in DS1 and add the row(s) to DS2. Then you can call the DS2.UPDATE method, because once again, the ADD KEYS have been inserted into the dataset's metadata.
HOPE THIS HELPS!
(took me forever to type it all out! ahahahaha)
October 4th, 2003, 01:50 PM
Thanks very much for your fast and informative reply.
The problem is solved, what i was trying to do is have an offline administration program so that I can do batch update for the online system.
The problem was that on the client side I used the UpdateCommand and InsertComand while on the server side I used the command builder so it seems that at some point there is incompatibility, when I used the UpdateCommnad and the InsertCommand on both sides it just worked fine.