T
TJoker .NET
Hi folks.
I'm having a data visibility issue when using distributed transactions but
I'm not sure if this is normal or I'm doing something wrong.
I have this object hierachy that is going to be saved as one transaction.
Each object has a Save() method that creates a SQLConnection and executes a
INSERT or UPDATE statement.
I have one object that is responsible for calling all those Saves in the
appropriate order. This object is deployed in COM+ (it is a
ServicedComponent with transaction required). Let's call this object the
Controller. In the Controlller my code looks simply like:
<AutoComplete(True)> _
Public Sub SaveAll(objParent as ParentType)
objParent.Save()
Dim child as ChildType
For Each child in objParent.Children
child.Save()
Next
End Sub
The Parent.Save executes a SQL statement like:
INSERT INTO parent (key1, col1, col2) VALUES (123, 'abc', 'def')
The Child Save does:
INSERT INTO child (key1, parentKey, col1) VALUES (789, 123, 'xyz')
The child table has an insert Trigger that validates that [parentKey] is a
valid [key1] in the parent table.
When I execute the Controller's SaveAll() method the trigger fails saying
that the parentKey (ex: 123) was not found in the parent table.
Is this normal considering that each Save method opens and closes a new
connection, or the trigger should be able to view the newly inserted row ??
Thanks for any feedback!
TJ!
I'm having a data visibility issue when using distributed transactions but
I'm not sure if this is normal or I'm doing something wrong.
I have this object hierachy that is going to be saved as one transaction.
Each object has a Save() method that creates a SQLConnection and executes a
INSERT or UPDATE statement.
I have one object that is responsible for calling all those Saves in the
appropriate order. This object is deployed in COM+ (it is a
ServicedComponent with transaction required). Let's call this object the
Controller. In the Controlller my code looks simply like:
<AutoComplete(True)> _
Public Sub SaveAll(objParent as ParentType)
objParent.Save()
Dim child as ChildType
For Each child in objParent.Children
child.Save()
Next
End Sub
The Parent.Save executes a SQL statement like:
INSERT INTO parent (key1, col1, col2) VALUES (123, 'abc', 'def')
The Child Save does:
INSERT INTO child (key1, parentKey, col1) VALUES (789, 123, 'xyz')
The child table has an insert Trigger that validates that [parentKey] is a
valid [key1] in the parent table.
When I execute the Controller's SaveAll() method the trigger fails saying
that the parentKey (ex: 123) was not found in the parent table.
Is this normal considering that each Save method opens and closes a new
connection, or the trigger should be able to view the newly inserted row ??
Thanks for any feedback!
TJ!