Table updating error: only the first row is updated.

jakocr

New member
Joined
Mar 13, 2006
Messages
1
Programming Experience
1-3
Hi! I have a data set with some tables. One of these tables has four fields: Plate, BuyDate, DisposalDate and Type.
Most of the time I have some rows on this table,
the user through a form is capable of modifying the BuyDate or DisposalDate fields of whichever row he or she wants.
All up to here is ok, the table in the dataset shows all the changes made by the user,
the problem comes when the Data Base is gonna be updated. Only the row in the first position (in the table) get its fields updated to the DB. I don't know what's happening..I've already checked the row state of each row that was changed, and it is ok (Modified).
I'll appreciate any kind of help.

Here I add some VB code:
VB.NET:
'oData is the DataSet that contains the table Asset (DTAsset).
'DTAsset has four fields: Plate, BuyDate, DisposalDate and Type.
Public Function updateAsset(ByVal oData As DataSet, ByVal table As String) As Boolean
loAdapter.TableMappings.Clear()
loAdapter.TableMappings.Add("Table", table)
loAdapter.InsertCommand = getInsertCommand()
loAdapter.UpdateCommand = getUpdateCommand()
loAdapter.DeleteCommand = getDeleteCommand()
 
Try
loAdapter.Update(oData)
Catch ex As Exception
MsgBox(ex.Message)
End Try
If Not oData.HasErrors Then
updateAsset = True
End If
End Function
 
'Im not including the other commands (insert, etc). 
Private Function getUpdateCommand() As OleDbCommand
If updateCommand Is Nothing Then
updateCommand = New OleDbCommand(Me.PROC_UPDATE, New OleDbConnection(Common.CONNECTION_STRING))
updateCommand.CommandType = CommandType.StoredProcedure
With updateCommand.Parameters
.Add(Me.PARAM_BUY_DATE, OleDbType.Date).SourceColumn = DTAsset.FIELD_BUY_DATE
.Add(Me.PARAM_DISPOSAL_DATE, OleDbType.Date).SourceColumn = DTAsset.FIELD_DISPOSAL_DATE
.Add(Me.PARAM_PLATE, OleDbType.Integer).SourceColumn = DTAsset.FIELD_PLATE
End With
End If
getUpdateCommand = updateCommand
End Function
 
Last edited by a moderator:
Back
Top