Posting a dataset to a database

  • Thread starter Thread starter vaj
  • Start date Start date
V

vaj

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
 
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.
 
Vaj,

If it are alone inserts of new rows and the schemas are complete equal (the
pocket pc dataset may miss columns exept the primary key), than it is
relative simple.

If it are also updates than it will be much more work, if the original
dataset is not retrieved from that database.

Therefore what is it?

Cor
 
thanks guys but i dont think i explained the problem correctly,sorry!
the thing im not looking to tranfer the datasets on to the database in
the device but to a remote server.
tried RDA but my sql server isnt compatible with the version of the
server i have on the device.So what me and my colligues thought was to
do a http posting to the serevr.but the problem is non of us know how
to do this.
could any of u tell me how to do this or is there anyother way i can
get this data transferred?
 
vaj, we understand the issue. what we are suggesting is setting up a
..NET web service on the server, creating a web method to process the
incoming dataset from your pocket pc, and then passing the dataset from
the pocket pc to the web service. you should read up on web services to
see how they work:

http://www.codeproject.com/dotnet/intro2websvc.asp

basically, the pocket pc will be the client or consumer of the web
service. on the app you are writing for the pocket pc, you include a
"web reference" to the web service server. then, on the pocket pc, you
call a method from the web service on the server, like:

MyWebService.UpdateData(dsUpdatedDataset)

This will send your dataset over to the web service, which can process
the modifications and write them to the database.

please post back to this thread with more questions instead of creating
another new thread on the newsgroup. you have triple-posted this
question already.
 
ok think i get it.,thanks guys
vaj, we understand the issue. what we are suggesting is setting up a
.NET web service on the server, creating a web method to process the
incoming dataset from your pocket pc, and then passing the dataset from
the pocket pc to the web service. you should read up on web services to
see how they work:

http://www.codeproject.com/dotnet/intro2websvc.asp

basically, the pocket pc will be the client or consumer of the web
service. on the app you are writing for the pocket pc, you include a
"web reference" to the web service server. then, on the pocket pc, you
call a method from the web service on the server, like:

MyWebService.UpdateData(dsUpdatedDataset)

This will send your dataset over to the web service, which can process
the modifications and write them to the database.

please post back to this thread with more questions instead of creating
another new thread on the newsgroup. you have triple-posted this
question already.
 
Back
Top