using a text file instead of dB

  • Thread starter Thread starter The Bear
  • Start date Start date
T

The Bear

After a dataset has been populated from a text file, is it possible to
update a text file from a dataset once changes are made?

TB
 
The Bear said:
After a dataset has been populated from a text file, is
it possible to update a text file from a dataset once changes
are made?

Sure ! The easiest way is to iterate through the dataset [I'm assuming one
data row -> one text line], converting each row to an appropriate text
representation [append column data and delimiters to a StringBuilder object
?], and then writing the text line out; this continues until the whole
dataset has been processed.

You would roughly proceed as follows:

open text file stream

foreach Row in Dataset
foreach Column in Row
append column and delimter to textline
write textline

close text file stream

Note that you will have replaced the existing text file rather than having
updated parts of it as you would with a dataset; it's generally easier to do
this than trying to randomly move through the file updating it.

I hope this helps.

Anthony Borla
 
DataSet has methods to write and load xml serialization

DataSet.ReadXml
DataSet.WriteXml

If you are using a not strong typed dataset, you'll probabily save also the
dataset schema
 
Back
Top