PC Review


Reply
Thread Tools Rate Thread

Deleting XML Record from Dataset removing table?

 
 
John
Guest
Posts: n/a
 
      4th Nov 2005
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.


 
Reply With Quote
 
 
 
 
Derek Harmon
Guest
Posts: n/a
 
      10th Nov 2005
"John" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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.WriteSchema argument like this,

// Dump tables in data set (with schema) to stdout.
dataSet.WriteXml( Console.Out, XmlWriteMode.WriteSchema);

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 indistinguishable
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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset update error (record requires parent table record) PAUL Microsoft ADO .NET 4 5th Oct 2005 03:46 PM
Dataset update error (record requires parent table record) PAUL Microsoft VB .NET 3 5th Oct 2005 03:35 PM
removing rows from a table in a dataset =?Utf-8?B?YW1iZXI=?= Microsoft Dot NET 0 27th Sep 2005 08:21 PM
Deleting from a table via a dataset positioning problem VB Learner Microsoft Dot NET Framework Forms 0 10th Mar 2005 10:36 AM
Index out of range error when deleting rows in dataset table with relationships defined between fields in the same table JerryK Microsoft ADO .NET 0 19th Sep 2003 06:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:09 PM.