COM+ objects

I am working on an application that has a COM+ DataAccess layer. So obviously all the transactions are done though the DTC so the business object that all other business objects inherit from is a child of the ServicedComponent class.
What I am finding is that class attribute values are lost when they are set in one method and then accessed in another. And sometimes even when they are set in one function they take a totally different value.
Ex
    Private requestId As Integer
 
    Public Overloads Function Insert(ByVal params As ParamContainer) As Integer
 
       'create the special request object
       requestId = MyBase.Insert("InsertStudSpRequest", params)
 
       'attach all the students that were added
       For Each stud As Student In Students
           'insert the student
           stud.Insert()
           'create the relationship to the request
           Database.ExecuteScalar(Constants.Database.SPECIALCASES_CONNNAME, "InsertSpecialRequestContact", requestId, stud.Attributes.StudentId)
       Next
       Students.Clear()
 
       'attach all the examiners to the special request
       For Each exr As Examiner In Examiners
           'insert the examiner
           exr.Insert()
           'create the relationship to the request
 
           Database.ExecuteScalar(Constants.Database.SPECIALCASES_CONNNAME, "InsertSpecialRequestContact", requestId, exr.Attributes.ExaminerId)
       Next
       Examiners.Clear()
 
       Return requestId
 
    End Function
=============
When setting the requestId in the first line huge numbers are found to be the value. If I remove the private requestId value within the class and declare the requestId within the function it works properly.
What it the reason for this  Thanks for the help



Answer this question

COM+ objects

  • bri189b

    Based on your issue, it seems that the transaction is getting committed as a result of which the data layer object is getting destroyed(deactivated). Now that you call another method which uses the requestID parameter it gets an uninitialized value of the requestID parameter.

    If the transaction is indeed going to be commited after the call to insert. You must fetch this value from the database rather then having it in a member variable.

    Also you must initialize the requestID parameter in your constructor to make sure you do not end up with garbage.



  • nutty nyce

    You have not given any details in terms of the configuration of your components. Therefore I just have speculations to offer at this point.If you commit the transaction the object state will be cleaned up as soon as the transaction is done.

    If you can give more details that would really help.



  • COM+ objects