tina33
04-03-2004, 01:41 AM
Hi Good People
I'm a newbie in .NET and looking for help in getting my small project started. I'm using textbox controls on a form to capture some details and create an in-memory cache of my records before I eventually save the collection of records created to an XML file.
The form will also have commandbuttons to allow me to insert a new record, go next record, got first record, etc (similar to the methods of a recordset). Each time I navigate to a different record, the textbox contents on the form should reflect the change. A SUBMIT command button should write all these records in memory to an XML file.
How can I allow navigation from one record to another, as well as record changes just the way we do in VB6.0 using the Recordset object? I couldn't see any way of doing it. Which object(s) in the Dataset namespace can I use?
PLEASE HELP!! Here's a simplified version of my code snippet:
Public Shared Sub SaveRecordsInDatatable
CreateDataSet
'Add data to table
Dim i As Integer
For i = 0 To 10
dr = dt.NewRow
dr("name") = txtName.text
dr("surname") = txtSurname.text
dr("DOB") = txtDOB.text
dt.Rows.Add(dr)
Next i
End Sub
Public Shared Sub CreateDataset()
Dim dt As New DataTable
Dim dc As DataColumn
Dim dr As DataRow
' Create new DataRow objects
'create name column
dc = New DataColumn
dc.DataType = System.Type.GetType("System.String")
dc.ColumnName = "name"
dt.Columns.Add(dc)
' Create surname column.
dc = New DataColumn
dc.DataType = Type.GetType("System.String")
dc.ColumnName = "surname"
dt.Columns.Add(dc)
' Create Date Of Birth column.
dc = New DataColumn
dc.DataType = Type.GetType("System.String")
dc.ColumnName = "DOB"
dt.Columns.Add(dc)
End Sub
P/S - some code snippets would help. Thanks.
I'm a newbie in .NET and looking for help in getting my small project started. I'm using textbox controls on a form to capture some details and create an in-memory cache of my records before I eventually save the collection of records created to an XML file.
The form will also have commandbuttons to allow me to insert a new record, go next record, got first record, etc (similar to the methods of a recordset). Each time I navigate to a different record, the textbox contents on the form should reflect the change. A SUBMIT command button should write all these records in memory to an XML file.
How can I allow navigation from one record to another, as well as record changes just the way we do in VB6.0 using the Recordset object? I couldn't see any way of doing it. Which object(s) in the Dataset namespace can I use?
PLEASE HELP!! Here's a simplified version of my code snippet:
Public Shared Sub SaveRecordsInDatatable
CreateDataSet
'Add data to table
Dim i As Integer
For i = 0 To 10
dr = dt.NewRow
dr("name") = txtName.text
dr("surname") = txtSurname.text
dr("DOB") = txtDOB.text
dt.Rows.Add(dr)
Next i
End Sub
Public Shared Sub CreateDataset()
Dim dt As New DataTable
Dim dc As DataColumn
Dim dr As DataRow
' Create new DataRow objects
'create name column
dc = New DataColumn
dc.DataType = System.Type.GetType("System.String")
dc.ColumnName = "name"
dt.Columns.Add(dc)
' Create surname column.
dc = New DataColumn
dc.DataType = Type.GetType("System.String")
dc.ColumnName = "surname"
dt.Columns.Add(dc)
' Create Date Of Birth column.
dc = New DataColumn
dc.DataType = Type.GetType("System.String")
dc.ColumnName = "DOB"
dt.Columns.Add(dc)
End Sub
P/S - some code snippets would help. Thanks.