Gustav Brock
Gustav at cactus.dk
Wed Sep 2 05:17:59 CDT 2009
Hi Stuart No manual parsing, no nothing except strongly typed data. For example, if the sys table does not exist (first time run of the app), this code does it all: // New location. Create empty data file with system table. DataSetDL.DataTableSysDataTable dataTableSys = DlDataSet.DataTableSys; DataSetDL.DataTableSysRow dataTableSysRow = dataTableSys.NewDataTableSysRow(); dataTableSysRow.SmtpServer = "localhost"; dataTableSys.AddDataTableSysRow(dataTableSysRow); dataTableSys.AcceptChanges(); DlDataSet.WriteXml(_dataBaseFile); I love simple code like this, readable in one scan. And this code (generated automatically behind the scenes on your order) binds the textbox to the field of the datatable: this.smtpServerTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataTableSysBindingSource, "SmtpServer", true)); But, of course, it's all a matter of taste. However, I've done enough construction and parsing of csv files previously to not miss that at all. I don't understand why I shouldn't tell this is easy in .Net - or rather Visual Studio - it _is_ easy! /gustav >>> stuart at lexacorp.com.pg 02-09-2009 11:19 >>> I'm well acquainted with it already thank you :-( 388 characters to transmit 58 characters of data and you need a full parsing engine to extract anything from it! In what way is that preferable to something like this: Id|SmtpServer|smtpUserName|SmtpPassword|EmailAddressSend|EmailAddressReceive 0|smtp.webpartner.dk|||cactus at cactus.dk|gustav at cactus.dk (Take your pick of delimiters, Pipes, Tabs, Nulls or anythiing else you want to use) And don't tell me "because it is easy in .Net" - I have similar feelings about .Net. -- Stuart On 2 Sep 2009 at 10:52, Gustav Brock wrote: > Hi Stuart > > To get acquainted with it. And it is simply too easy to justify reinventing a custom method. > Also, it is easy to document and to explain for some other developer who may wish to read the data. > > For example, read one XML file with one dataset containing several tables: > > private void InitializeDataSet() > { > _dataBaseFile = Path.Combine(_execPath, _dataFileName); > this.DlDataSet.ReadXml(_dataBaseFile); > } > > Write the (modified) dataset to one XML file: > > private void SaveData() > { > this.DlDataSet.WriteXml(_dataBaseFile); > } > > Resulting XML for one table with one record: > > <?xml version="1.0" standalone="yes"?> > <DataSetDL xmlns="http://tempuri.org/DataSetDL.xsd"> > <DataTableSys> > <Id>0</Id> > <SmtpServer>smtp.webpartner.dk</SmtpServer> > <SmtpUserName /> > <SmtpPassword /> > <EmailAddressSend>cactus at cactus.dk</EmailAddressSend> > <EmailAddressReceive>gustav at cactus.dk</EmailAddressReceive> > </DataTableSys> > </DataSetDL> > > /gustav