esposito
Centurion
Hello, I need your help. I have created a very simple XML file, called "news.xml", structured in the following way:
In order to populate the XML file above, I use the following code:
As you can see, I have used a Label (lblRecordNumber) to keep track of the current record number. This number could be referred to as an ID when you want to search for a record.
Now, my question is, is there any way I can update or delete a record from the database?
TIA
Code:
<News_Database>
<My_News>
<news1>First News A</news1>
<news2>Second News A</news2>
</My_News>
<My_News>
<news1>First News B</news1>
<news2>Second News B</news2>
</My_News>
<My_News>
<news1>First News C</news1>
<news2>Second News C</news2>
</My_News>
</News_Database>
In order to populate the XML file above, I use the following code:
Visual Basic:
Sub btnSaveRecord_Click(sender As Object, e As EventArgs)
Try
Dim objDataSet As New System.Data.DataSet
objDataSet.ReadXml("news.xml")
Dim News1_Var As String
Dim News2_Var As String
News1_Var = txtNews1.Text
News2_Var = txtNews2.Text
Dim v(1) As String
v(0) = News1_Var
v(1) = News2_Var
objDataSet.Tables(0).Rows.Add(v)
objDataSet.WriteXml("news.xml")
Dim count As Integer
objDataSet.ReadXml(Server.MapPath("news.xml"), XmlReadMode.Auto)
count = objDataSet.Tables(0).Rows.Count
lblRecordNumber.Text = count / 2
Catch ex As Exception
Exit Sub
End Try
End Sub
As you can see, I have used a Label (lblRecordNumber) to keep track of the current record number. This number could be referred to as an ID when you want to search for a record.
Now, my question is, is there any way I can update or delete a record from the database?
TIA