473,661 Members | 2,431 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting XML Record from Dataset removing table?

Hi All,
When I delete the last record from my dataset and then WriteXML() to the
file; the Table itself, in the xml file, is removed. I need to prevent the
table structure from being deleted if there are no more records to be
written to the XML file from the Dataset.

Any ideas here,
John.
Nov 12 '05 #1
1 1998
"John" <jr***@patmedia .net> wrote in message news:eE******** *****@TK2MSFTNG P09.phx.gbl...
When I delete the last record from my dataset and then WriteXML() to the file; the Table itself, in the xml file, is removed. I
need to prevent the table structure from being deleted


There will be no records from the empty table in the data written to the
XML instance doc, that's correct, but the table structure still exists in the
schema. If you're taking this XML from one DataSet and reconstructing
the DataSet somewhere else, then having the schema definition present
should suffice as far as creating empty DataTables in the new DataSet.

You can include the schema in your XML by calling WriteTo( ) with the
XmlWriteMode.Wr iteSchema argument like this,

// Dump tables in data set (with schema) to stdout.
dataSet.WriteXm l( Console.Out, XmlWriteMode.Wr iteSchema);

Were the DataSet's XML serializer to produce an empty row with
empty values in each column to persist the empty table's "structure, "
such XML in the instance document would be indistinguishab le
from a real row - all of whose columns had empty string values.

While there may be kludges to arrive at a similar effect (for instance,
custom serialization/deserialization that embeds DataTable schema info
in a comment that you do on both sides), using the XML schema
definition is the best place to hold this metainformation .
Derek Harmon
Nov 12 '05 #2

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

Similar topics

0
3635
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
3
12275
by: Christoph | last post by:
I'm delving into using ADO.NET for the first time. In fact, I've never done any database work using C# at all so all of this is new to me. Please bear that in mind if I am asking stupid questions. In reading the documentation for the "Update()" method of the SqlDataAdapter class, I see that it "Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated or deleted rows in the specified array of DataRow objects"....
3
1756
by: Abra | last post by:
My C# application has a list (ListBox object), connected over a DataView to a dataset which corresponds to a table from a MySql database. I want to delete for example 4000-5000 rows from the table, which correspond to a certain filter. If I iterate the Rows from the table and check for each one the filter condition and, if true, I call the Delete() method, it takes several minutes till the respective rows are deleted. I tried also to...
2
1708
by: NDady via DotNetMonster.com | last post by:
Hi, I have a datagrid populated from a dataset. On every row in the grid I have a delete button. When the user presses on the delete button I remove the row from the dataset and rebind the datagrid. The problem is that after a couple of delete the index in the dataset does not match the index in the grid and the wrong record i deleted from the dataset. How can I solve this Problem? I am using the following procedure: Private Sub...
5
3758
by: Robert Brown | last post by:
Hi All. I have a routine that checks a SQL Table for all records 3 months prior to a predetermined date, then I insert them into an Archive DB then delete those records from the original table. When I do a "select" for the records, I load them into a dataset, use an "insert" statement to insert the info into the second table (by a for next loop and using executenonquery , then a "delete" statement to remove them.
0
1101
by: Lisa Jones | last post by:
Hi Has anyone see this problem in ADO.Net when deleting a record (assuming that the table has identity increment Index) result in getting wrong index key if right after adding the record the table query for the added recorded Index key. Anyone knows what would be the best way to solve this problem Clearing dataset and refilling it won’t work if you are using web services. Any suggestion or help will be highly appreciated Thank Lisa...
0
1747
by: Andy_Khosravi | last post by:
I'm having a problem trying to optimize the performance of one of my A97 databases. I have very slow record navigation after a change I made to the table structure, and I'm not sure how best to correct it. For purposes of explanation, lets say I have two tables: tblIssues and tblLocationHistory. The tblIssues table contains 'incidents' along with the incident header information. The tblLocationHistory table contains a list of all...
7
6601
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer include them in the set that is displayed to the user) but I don't want to delete the corresponding row from the database. I've tried using the .Rows.Remove() method but an exception is thrown to say I don't have a 'delete' command in the data...
11
3665
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night) and the 'employee name'. There is another table which assigns an ID to the Shifts, i.e. 1,2 and 3 for morn, eve & night shifts respectively. From the mother table, the incentive is calculated datewise for each employee as per his shift duty. In...
0
8432
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
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8758
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...
0
8633
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...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4179
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
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
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.