S
Shan1986
Guest
Hallo ,
I have made this example, i can save file as xml and read back to dataset using readxml but i dont know how to create new file or empty dataset with button click for creating new file from empty dataset. How it should be done?
Public Class Form1
Public DS As DataSet = New DataSet("Project")
Public table1 As DataTable = New DataTable("Medications")
Public BS As New BindingSource
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With table1
.Columns.Add("id")
.Columns.Add("medication")
End With
' Create the DataSet.
DS.Tables.Add(table1)
BS.DataSource = DS.Tables("Medications")
DataGridView1.DataSource = BS
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles save.Click
DS.WriteXml("DS.xml")
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles new_row.Click
table1.Rows.Add(1, "atenolol")
table1.Rows.Add(6, "trifluoperazine")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles open.Click
DS.ReadXml("DS.xml")
End Sub
End Class
Thanks
Continue reading...
I have made this example, i can save file as xml and read back to dataset using readxml but i dont know how to create new file or empty dataset with button click for creating new file from empty dataset. How it should be done?
Public Class Form1
Public DS As DataSet = New DataSet("Project")
Public table1 As DataTable = New DataTable("Medications")
Public BS As New BindingSource
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With table1
.Columns.Add("id")
.Columns.Add("medication")
End With
' Create the DataSet.
DS.Tables.Add(table1)
BS.DataSource = DS.Tables("Medications")
DataGridView1.DataSource = BS
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles save.Click
DS.WriteXml("DS.xml")
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles new_row.Click
table1.Rows.Add(1, "atenolol")
table1.Rows.Add(6, "trifluoperazine")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles open.Click
DS.ReadXml("DS.xml")
End Sub
End Class
Thanks
Continue reading...