read and write to xml

J

jaYPee

i read some article that it's better to store some information to xml
than using an ini file. suppose to be i want to read and write this
data:

file name="my.ini"

[ConnectionString]
Server="myServer"
UID="myUID"
Password="myPassword"
Database="myDatabase"

so anybody know how can i do this in vb.net? i want to know what is
the server name, uid, password, database. i want to read from xml to
be use by my sql connection.

thanks in advance
 
W

William Ryan eMVP

The really easy was is to create a datatable with 4 columns, add a row,
store those values, and then use DataSet.WriteXML(@"Path:\File.xml"); You
can reference the values by myDataSet.Tables[0].Rows[0][0] for the first
column [0][1] for the second etc.

You can just use myDataSet.ReadXML(@"Path:\File.xml") and reference just as
above

Another easy was is storing it iin the Config file.
http://www.knowdotnet.com/articles/configfiles.html which you can do very
easily and use DynamicProperties.
You can also make a class and specify it as serializable, use attributes for
each property and use Serialize Deserialize

Using ini files isn't 'bad' it's just old school and there are easier, more
OOP way like config files.
HTH,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top