473,856 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Manipulating XML data - using a DataSet

Part of an application I'm working on needs to manipulate some XML data (in
an XML file), by reading the data into a DataSet using the MyDataSet.ReadX ML
method, and then using MyDataSet.Write XML to update the XML file itself.
However, now I want to take advantage of the Primary Key functionality of
the DataSet object, so I can easier find rows (in a DataTable in the
DataSet), and also easier remove rows, based on a unique key.
Unfortunately, I'm not sure how that will impact how the XML looks (and I
cannot change the format of that file - it's already used by other
applications).
Here's a snippet of the XML I'm using:

<?xml version="1.0" ?>
<Cache>
<FileCache>
<FileName>Book1 .xls</FileName>
<FilePath>C:\Wi ndows\Temp</FilePath>
<OID>3838.64847 .26094.60105</OID>
<DateTime>4/5/2005 9:50:45 AM</DateTime>
</FileCache>
<FileCache>
<FileName>Book2 .xls</FileName>
<FilePath>C:\Wi ndows\Temp</FilePath>
<OID>3838.64847 .18503.25804</OID>
<DateTime>4/5/2005 9:50:56 AM</DateTime>
</FileCache>
</Cache>
The field I need to use as primary key (should be unique) is the OID field.

As you can see, reading that data into a Dataset gives me a DataTable called
Cache, with rows called FileCache (where OID is the third column in those
rows).
How do I tell it to use that column as the primary key, even after I've
loaded it via the LoadXML method, and then how do I do the SaveXML without
adding anything else to the XML layout than what you see above?
Thanks!
Nov 21 '05 #1
1 1778
Never mind everybody... Managed to find the solution myself... :)

If anyone else is having this issue, here's my solution.

After the ReadXML, I added the following line:

MyDataSet.Table s("Cache").Prim aryKey = New DataColumn()
{_MyDataSet.Tab les("Cache").Co lumns("OID")}

"Scott M. Lyon" <sc************ ******@rapistan .BLUE.com> wrote in message
news:ue******** ******@TK2MSFTN GP09.phx.gbl...
Part of an application I'm working on needs to manipulate some XML data
(in an XML file), by reading the data into a DataSet using the
MyDataSet.ReadX ML method, and then using MyDataSet.Write XML to update the
XML file itself.
However, now I want to take advantage of the Primary Key functionality of
the DataSet object, so I can easier find rows (in a DataTable in the
DataSet), and also easier remove rows, based on a unique key.
Unfortunately, I'm not sure how that will impact how the XML looks (and I
cannot change the format of that file - it's already used by other
applications).
Here's a snippet of the XML I'm using:

<?xml version="1.0" ?>
<Cache>
<FileCache>
<FileName>Book1 .xls</FileName>
<FilePath>C:\Wi ndows\Temp</FilePath>
<OID>3838.64847 .26094.60105</OID>
<DateTime>4/5/2005 9:50:45 AM</DateTime>
</FileCache>
<FileCache>
<FileName>Book2 .xls</FileName>
<FilePath>C:\Wi ndows\Temp</FilePath>
<OID>3838.64847 .18503.25804</OID>
<DateTime>4/5/2005 9:50:56 AM</DateTime>
</FileCache>
</Cache>
The field I need to use as primary key (should be unique) is the OID
field.

As you can see, reading that data into a Dataset gives me a DataTable
called Cache, with rows called FileCache (where OID is the third column in
those rows).
How do I tell it to use that column as the primary key, even after I've
loaded it via the LoadXML method, and then how do I do the SaveXML without
adding anything else to the XML layout than what you see above?
Thanks!

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
3048
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
5
2140
by: Kevin C | last post by:
I was curious to know what some developers out in the industry are doing when it comes to exposing Data access logic, specifically persistence. This is assuming that your not using an O/R framework or something that completely abstracts you from the persistence details. Are you: 1. Having simple data type interfaces and the data layer know nothing about the domain models. For example: public int SaveCustomer( string fname, string...
2
2002
by: mark | last post by:
Hi, I have a dataset, DataSetTemp which gets filled by the DataAdapter when querying a SQL Server database. Only one table is populated in the data set. I have another dataset, DataSetResults, which has two tables in it DataTableResults and DataTableExceptions. I want to add all the rows from DataSetTemp.DataTable to DataTableResults. Bear in mind there is already data in this table, which must be preserved - I just want to...
3
2150
by: ASzasz | last post by:
I am new to VB .NET: I can configure a SQL adapter and access data via the datagrid. But how do you access and manipulate data if you do not require the data to show up on a form. I simply want to audit a SQL table's data using code to cycle through all records. The user doesn' t need to see the table data. Any help appreciated.
2
1598
by: Daniel Kaseman | last post by:
What's the best way to manipulate a Microsoft Access Database from VB .Net? I have gotten as far as making and configuring a OleDbAdapter, connection, and Dataset, which is bound to a data grid. I'm able to see the data in the table on the data grid when my VB program is running, and I can type new data in, but I don't know how to actually update the database file (*.mdb file). So what's the best way to do this. I don't want to do...
1
1185
by: Jean Christophe Avard | last post by:
Hi! I am designing an application, and I need some pointers. I have a database that has 5 tables: a table "Items" and 4 other table that has relationship to "Item". I have to retreive all the records, and browse through it. I know how to populate a dataset with all the records, but what I need to know is How to browse through the record and display them in textboxes on a form. Let's say I have a form with 5 textboxes. When the form load,...
2
7826
by: michael sorens | last post by:
I have been trying to figure out how to use DataSets, BindingSources, DataGridViews, and XML together, but it is a challenge. I understand how to populate a DataGridView with XML basically as: DataSet ds = new DataSet(); ds.ReadXml(@"\usr\tmp\sample.xml"); dataGridView.DataSource = ds; dataGridView.DataMember = "targetElement"; What I found through experimentation is that the DataMember may specify
0
867
by: Arturo | last post by:
I have constructed a Dataset using visual studio, where tables from my database were dragged and drop into the dataset design page. I wrote code to read data from the database by declaring and creating an instance of the data set, creating a table adapter then filling the dataset using the table adapter. Now I am capable of retrieving data from the database, but I am having a hard time understanding how to save data to the data table. ...
5
2021
by: Anil Gupte | last post by:
How can I manipulate Datasets, such as getting a specific row based on a key column value. Of course, I could loop through all the rows in the entire dataset each time I needed something, but is there an easier way? I want to be able to execute the equivalent of SQL statements including insert, delete etc. Any ideas? Thanx, -- Anil Gupte www.keeninc.net
0
9921
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11065
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10795
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9536
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7098
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5962
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.