G
Guest
Thanks in advance for any help.
I am using code that is directly from David Sceppa's book from MS Press
titled "ADO.NET".
I have walked completely though the code and I find values are what they
should be until I reach the following subroutine.
Private Sub SubmitChangesByHand()
Dim cmdUpdate As System.Data.OleDb.OleDbCommand =
CreateUpdateCommand()
Dim row As System.Data.DataRow
Dim intRowsAffected As Integer
Dim dvrs As System.Data.DataViewRowState
dvrs = System.Data.DataViewRowState.ModifiedCurrent Or
System.Data.DataViewRowState.Deleted Or System.Data.DataViewRowState.Added
For Each row In tbl.Select ("", "", dvrs)
msgbox("in the for loop")
intRowsAffected = SubmitUpdate(row, cmdUpdate)
msgbox(intRowsAffected)
if intRowsAffected = 1 then
row.AcceptChanges()
else
row.RowError = "Update attempt failed"
End If
Next row
End Sub
For some reason I am not getting inside the For loop. Only thing I can see
is that the DataViewRowState is returning a value of 28 which should be 16
(for updating a database). I invoke the function by a button click event
elsewhere in the code.
Other than that, the table has records in it which is declared elsewhere as:
Dim tbl As New System.Data.DataTable("categories")
I am using the Northwind database in my trial efforts.
I am using code that is directly from David Sceppa's book from MS Press
titled "ADO.NET".
I have walked completely though the code and I find values are what they
should be until I reach the following subroutine.
Private Sub SubmitChangesByHand()
Dim cmdUpdate As System.Data.OleDb.OleDbCommand =
CreateUpdateCommand()
Dim row As System.Data.DataRow
Dim intRowsAffected As Integer
Dim dvrs As System.Data.DataViewRowState
dvrs = System.Data.DataViewRowState.ModifiedCurrent Or
System.Data.DataViewRowState.Deleted Or System.Data.DataViewRowState.Added
For Each row In tbl.Select ("", "", dvrs)
msgbox("in the for loop")
intRowsAffected = SubmitUpdate(row, cmdUpdate)
msgbox(intRowsAffected)
if intRowsAffected = 1 then
row.AcceptChanges()
else
row.RowError = "Update attempt failed"
End If
Next row
End Sub
For some reason I am not getting inside the For loop. Only thing I can see
is that the DataViewRowState is returning a value of 28 which should be 16
(for updating a database). I invoke the function by a button click event
elsewhere in the code.
Other than that, the table has records in it which is declared elsewhere as:
Dim tbl As New System.Data.DataTable("categories")
I am using the Northwind database in my trial efforts.