473,804 Members | 4,005 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 1775
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
3040
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
2135
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
2001
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
2147
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
1597
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
1182
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
7823
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
865
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
2020
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
10330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10319
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
10076
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
9144
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
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
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
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
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.