Hi John:
Is the scenario basically that you are pulling data from a Web service and
now you need to get that data into an Access DB Table? I'm probably just
restating the obvious but I just want to confirm this. If so, comments
below:
John said:
Hi
I have a dataset which has received its data from a remote web service. How
can I now save the dataset into a local access table?
In the WS, make sure that you set the DataAdapter's ..AcceptChangesDuringFill
property to false.
http://www.knowdotnet.com/articles/datasetmerge.html
What this will do is (as the name may suggest), suppress the Adapter from
calling AcceptChanges on each row as it's added to the datatable. That will
have the effect of having the Rowstate for each row set to Added instead of
Unchanged. So, if each row is marked as Added, then all you need is a valid
Update command for a data adapter configured for the Access DB table, and
you can just call Update on the dataset.
So, in the WS, remeber to set the AcceptChangesDuringFill to false
WebService As DataSet
//Set it to False here.
//Call Fill on the Dataset
//Return Data Set
now, in your client app. Make sure you create your web reference correctly
and then invoke the ws
DataSet ds = myWebService.GetDataSetMethod();
//At this point, your dataSet will HasChanges=True... Test it just to be
sure
Debug.Assert(ds.HasChanges, "DataSet doesn't have Changes");
//The reason for this check during debug phase is just to ensure that it has
changes, otherwise calling update on it will do nothing - This isn't
necessary for production, you just want to make sure that if your update
doesn't work that it's not because the dataset didn't have any changes
//Now assuming you have an OleDbDataAdapter and its update command is
configured properly....
myOleDbDataAdapter.Update(ds.Tables[0]);
//You can use any of the Overloads for Update, just make sure you specify
the right table. You may for instance have multiple tables pulled back from
the WS, in that case, you'll need multiple DataAdapters and you'll need to
fill the parent tables first b/c of the Key constraints if they are
applicable.
Let me know if you have any questions.
HTH,
Bill
--
W.G. Ryan MVP Windows - Embedded
http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/