G
Guest
I've been trying to insert a record to my already existing dataset which I
have it in my session and I don't know what is going on but, I got it to
create a datatable with the new row but, when I tried to append to my
exisiting dataset, the row does not get inserted. I did step through the
code, I can see that myTable has that record and dataset has 1000 rows and it
should be 1001 after performing _testDataSet.AcceptChanges(). What am I
doing wrong here. Please help. Thanks.
Henry
Code:
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Dim _testDataSet As DataSet = Session("testDataSet")
Dim myTable As DataTable
Dim myRow As DataRow
Dim myColumn As DataColumn
Dim adapter As New SqlDataAdapter
myColumn = New DataColumn
myColumn.DataType = "System.String"
myColumn.ColumnName = "col1"
myTable.Columns.Add(myColumn)
myColumn = New DataColumn
myColumn.DataType = "System.String"
myColumn.ColumnName = "col2"
myTable.Columns.Add(myColumn)
myRow("col1") = "John"
myRow("col1") = "doe"
myTable.Rows.Add(myRow)
adapter.Update(_testDataSet)
_testDataSet.AcceptChanges()
Session("testDataSet") = _testDataSet
have it in my session and I don't know what is going on but, I got it to
create a datatable with the new row but, when I tried to append to my
exisiting dataset, the row does not get inserted. I did step through the
code, I can see that myTable has that record and dataset has 1000 rows and it
should be 1001 after performing _testDataSet.AcceptChanges(). What am I
doing wrong here. Please help. Thanks.
Henry
Code:
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Dim _testDataSet As DataSet = Session("testDataSet")
Dim myTable As DataTable
Dim myRow As DataRow
Dim myColumn As DataColumn
Dim adapter As New SqlDataAdapter
myColumn = New DataColumn
myColumn.DataType = "System.String"
myColumn.ColumnName = "col1"
myTable.Columns.Add(myColumn)
myColumn = New DataColumn
myColumn.DataType = "System.String"
myColumn.ColumnName = "col2"
myTable.Columns.Add(myColumn)
myRow("col1") = "John"
myRow("col1") = "doe"
myTable.Rows.Add(myRow)
adapter.Update(_testDataSet)
_testDataSet.AcceptChanges()
Session("testDataSet") = _testDataSet