?
Solved

Working with datasets

Posted on 2005-04-01
6
Medium Priority
?
243 Views
Last Modified: 2010-04-23
Alright here we go!! I'm writing an app and for that apps datastore I want to use a couple xml files. My vision is that when the app loads it reads the xml into a dataset that I work with while the app is running and then write that dataset back to xml upon closing the application, sounds simple enough right!! Here is where my idea goes downhill. I don't know how to "work" with the data in the dataset. Say I wanted to delete all records with say an "A" in the status field. If I were working against a database I'd say "delete * from table where status = A", how do I do that when referring to a dataset? Can I use a dataadapter that points to the dataset? Basically I would like to use sql against a dataset but have a feeling that can't be done. If so do I need to learn xquery or something of that sort.

Extreme appriciation to whomever is able to help me with this.
0
Comment
Question by:airwaysfreight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Expert Comment

by:Wim_Bl
ID: 13682650
Hi,

an exhaustive way could be: once the dataset is filled, loop through the rows, check the desired item and delete the row if necessary, like:

dim dr as DataRow
for each dr in ds.tables("someTable").Rows
    if dr.item("someColumn") = ...
   ...
next

I have no knowlegde of more "advanced" techniques.  Practically, when using XML-data, I load the XML-file into a DOM-object and then work with this, in combination with all the methods that are provided with it to modify it's data (find node, delete node, add node, etc...) With XPath, you can use a sort of query language for this DOM-object. Finally, I save the entire DOM back to the file. I believe this may be a better solution for your type of problem.

greetings!
0
 
LVL 2

Expert Comment

by:rrbecker
ID: 13686023
Hi Wim_Bl,

(1) Do you have a way of loading the XML into your database?
(2) or Are you just  looking for a way to manipulate the data after it is stored?

rrbecker
0
 
LVL 2

Expert Comment

by:rrbecker
ID: 13686061
Hi Wim_Bl,

I read your question again, maybe I don't have anything to offer....

Sorry,

rrbecker
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Accepted Solution

by:
arif_eqbal earned 1000 total points
ID: 13686456
hi airwaysfreight

Well you can't use SQL with Datasets but you have better options still
say for eg. you need to Delete all records with Status=A

say you have filled in a Dataset DS like this

       DS.ReadXml("C:\ds.xml")

Then to Delete All rows with Status=A

        Dim DR As DataRow
        For Each DR In DS.Tables(0).Select("Status='A'")
            DR.Delete()
        Next

similarly you have all the possibilities with you
0
 

Author Comment

by:airwaysfreight
ID: 13697465
Hi arif_eqbal

Can I use multiple criteria in your example above?

Ex.
For Each DR In DS.Tables(0).Select("Status='A' or CustNumber=-'12345'")

Thanks
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 13705984
Yes of course
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question