P
PAUL
Hello,
I have 2 tables with a relationship set up in the dataset with vb
..net. I add a new record to the parent table then edit an existing child
record to have the new parent ID. However when I do the update the changed
parentid in the child table fails to change. No error is given its just that
the change is not written to the Database.
When I step through the records for the child table the one I would expect
to be changed has a row state of Unchanged!
Basically in the child table I have at the start:
ParentID
1664
1665
1666 <------ParentID to change
---------
1666 parentid gets changed to -1 as thats the new ID of the parent table
record, the -1 being a temporary placeholder.
The parent table record goes in fine and is there when I look in the
database after the update has been done.
Update code
Try
daAffectedObjects.DeleteCommand.Transaction = trnMain
daAffectedObjects.InsertCommand.Transaction = trnMain
daAffectedObjects.UpdateCommand.Transaction = trnMain
daAffectedObjects.UpdateCommand.CommandText = _
"UPDATE tblAffectedObjects " & _
"SET Archived = ?, CheckedOutBy = ?, CheckedOutDatabase = ?, " & _
"CheckedOutDate = ?, Description = ?, IssueID = ?, ObjectID = ?, " & _
"CheckedInDate = ? " & _
"WHERE ID = ?"
daAffectedObjects.Update(dsIssue, "tblAffectedObjects")
Catch dbcx As DBConcurrencyException
createMessage(dbcx)
Catch err As Exception
MsgBox(Me.Name & _
System.Reflection.MethodBase.GetCurrentMethod().Name & vbCrLf & _
"Affected objects update failed - can not update issue" & vbCrLf & _
"Description : " & err.ToString & vbCrLf & _
"Line Number : " & Erl())
trnMain.Rollback()
btnUpdate.Enabled = True
btnCancel.Enabled = True
If OleDbConnection1.State = ConnectionState.Open Then
OleDbConnection1.Close()
End If
Exit Sub
Finally
End Try
I have 2 tables with a relationship set up in the dataset with vb
..net. I add a new record to the parent table then edit an existing child
record to have the new parent ID. However when I do the update the changed
parentid in the child table fails to change. No error is given its just that
the change is not written to the Database.
When I step through the records for the child table the one I would expect
to be changed has a row state of Unchanged!
Basically in the child table I have at the start:
ParentID
1664
1665
1666 <------ParentID to change
---------
1666 parentid gets changed to -1 as thats the new ID of the parent table
record, the -1 being a temporary placeholder.
The parent table record goes in fine and is there when I look in the
database after the update has been done.
Update code
Try
daAffectedObjects.DeleteCommand.Transaction = trnMain
daAffectedObjects.InsertCommand.Transaction = trnMain
daAffectedObjects.UpdateCommand.Transaction = trnMain
daAffectedObjects.UpdateCommand.CommandText = _
"UPDATE tblAffectedObjects " & _
"SET Archived = ?, CheckedOutBy = ?, CheckedOutDatabase = ?, " & _
"CheckedOutDate = ?, Description = ?, IssueID = ?, ObjectID = ?, " & _
"CheckedInDate = ? " & _
"WHERE ID = ?"
daAffectedObjects.Update(dsIssue, "tblAffectedObjects")
Catch dbcx As DBConcurrencyException
createMessage(dbcx)
Catch err As Exception
MsgBox(Me.Name & _
System.Reflection.MethodBase.GetCurrentMethod().Name & vbCrLf & _
"Affected objects update failed - can not update issue" & vbCrLf & _
"Description : " & err.ToString & vbCrLf & _
"Line Number : " & Erl())
trnMain.Rollback()
btnUpdate.Enabled = True
btnCancel.Enabled = True
If OleDbConnection1.State = ConnectionState.Open Then
OleDbConnection1.Close()
End If
Exit Sub
Finally
End Try