Dataset to Access DB

  • Thread starter Thread starter T Cordon
  • Start date Start date
It depends on how you got those records there. If the Rowstate of each row
is "Added" then all you need to do is provide a valid Insert command to your
dataadapter and call the .Update method of the adapter. So, if you are
filling it from another table in this db or another db, then when you call
DataAdapter.Fill from the original adapter, set the .AcceptChangesDuringFill
property to false. This will cause all of the records inserted to have a
rowstate or Added. Then call .Update with an adapter who's update command
is pointing to the destination table, and they'll all be inserted.
http://www.knowdotnet.com/articles/datasetmerge.html

Otherwise, you may need to take a different approach. If whatever approach
you used (like manually adding the rows) cause the Rowstate to be added, the
same will hold true. Otherwise, you may have to loop through the Dataset,
and use the values as paramaters for an insert statement or use the values
to manually build an insert statement, then calling executeNonQuery. By far
calling update is the easisest. You can check if the dataset has changes
via DataSet.HasChanges and if so, let me know what the rowstate is if it's
not added, I'll walk you through the second approach I mentioned here.

HTH,

Bill
 
Hi, Thanks for your repply.

It seems to be pointing me to the right direction but I just can't get it to
work.

What I am trying to to is to update an Access DB using a web service. So int
the local App (WinForms - VB) I get all the tables in the database, and for
earch one, fill a dataset that I send to the webservice. The structure of
the DB is exactly the same in both places. The web service is supposed to
get the dataset and and table name, drop all current records and insert all
the records it got from the dataset it received.

Any help is greatly appreciated.

Thanks Again.
 
Thank you all. Got it working... sort of. Just getting this error sometimes:

Additional information: System.Web.Services.Protocols.SoapException: There
was an exception running the extensions specified in the config file. --->
System.Web.HttpException: Maximum request length exceeded.
at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.get_InputStream()
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
--- End of inner exception stack trace ---

Any Ideas?

Thanks
 
T:

Does the web service automatically infer that it's going to insert
everything (ie the update logic is such that it doesn't use Rowstate to
insert the rows, it just loops through them and adds them no matter what)?
Or does it depend on Rowstate?
 
I get this in while trying to transfer the largest table DataSet, about 6000
records.

Thanks for your help
 
HOw big is the data... Look in machine.config and check out he
maxRequestLength attribute... if I remember correctl it's in httpRunTime
element.

Anyway, make this larger (may be trial and error unless you know the rough
size of the data you are transferring). If ti's the access db, it's pretty
easy to get ann esitmate of. To test it first, just try the original
approach, but change your fill query so you only pass 20 records. See if
that works. If so, this is almost certinaly the culprit. Either way, I'm
85% sure this is it if it's the only problem you are having now.
 
Yes, it works now. Had to change the maxRequestLength to a higher number
because a couple of table had ~ 70K records

But it worked.

I am now trying to optimize it and only send the new or modified records
comparing original DB table dataset with modified DB table Dataset so I can
send only those.

:)
 
I'm getting one more error: Even when I do this with databases that have the
same structure in some tables I get this error:

-2147217900 Syntax error in INSERT INTO statemente.

Please need Help

Thanks
 
Back
Top