Hello friends I trying to save and retrieve data in xml file using vb.net first of all I add a xml file (emp.xml) from add new item -> add some dummy data into it like
<serverinfo>
<servername>abc</servername>
<serverpwd>123</serverpwd>
</serverinfo>
copy the file from application folder to debug folder and write the following code on for save data :-
Dim path As String = Application.StartupPath & "\emp.xml"
Dim dt As New DataTable("emp")
Dim ds As New DataSet()
ds.ReadXml(path)
dt.Columns.Add(New DataColumn("eid", Type.[GetType]("System.Int32")))
dt.Columns.Add(New DataColumn("ename"))
Dim r As DataRow = ds.Tables(0).NewRow()
r(0) = TextBox1.Text
r(1) = TextBox2.Text
ds.Tables(0).Rows.Add(r)
ds.WriteXml(path)
and for display data into datagridview named (dg_Data)
Dim path As String = Application.StartupPath & "\emp.xml"
Dim ds As New DataSet()
ds.ReadXml(path)
dg_Data.DataSource = ds.Tables(0)
But it give some error when it read the xml file the error is "Root element is missing" so please help me..
Thanks in advance
Parveen Rathi