dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Recordset does not update in business object

  1. #1
    Dave Barker Guest

    Recordset does not update in business object


    I have a middle tier bis. object - I pass it the active connection then it
    appears to update the database but when i check the database afterwards the
    table has not been updated. If i use the exact same code within the client
    application the database is updated correctly. I think i am missing something
    in ADO but for the life of me I do not see what. Any help would be appreciated.

    The client code;

    ' Ref to the proActive clsActive class
    Dim WithEvents MyActive As clsActive

    ' Call ActiveX EXE (the business object
    Set MyActive = New clsActive
    MyActive.GetActive fMainForm.ADOConnRef, ts

    The reference fMainForm.ADOConnRef is application reference to the active
    connection which comes from an Active X DLL and ts is a TextStream.

    The business object code;

    Public Sub GetActive(ByRef ActiveConnRef As clsADOConn, _
    ByRef ActiveTextStream As TextStream)
    Dim lngR As Long
    Dim strM As String * 9
    Dim strP As String * 8
    Const strSQL = "SELECT * FROM tblActive"

    On Error GoTo ErrTrap
    ' Make the connection to the Main Application
    ' and open the recordset.
    Set objAXConn = ActiveConnRef

    Set ActiveRS = objAXConn.GetRS("DELETE * FROM tblActive")
    Set ActiveRS = Nothing
    Set ActiveRS = objAXConn.GetRS(strSQL)

    'Takes a Active Connection and textstream then updates the db
    'Skip to First valid record
    ActiveTextStream.Skip (279)
    'Start update

    Do While Not lngR = 10 'ActiveTextStream.AtEndOfStream
    lngR = lngR + 1
    ActiveRS.AddNew
    ActiveRS.Fields(0) = lngR
    ActiveRS.Fields(1) = ActiveTextStream.Read(9)
    ActiveTextStream.Skip (161)
    ActiveRS.Fields(2) = ActiveTextStream.Read(8)
    ActiveTextStream.Skip (101)
    'Updates the calling program
    RaiseEvent RecordCount(lngR)
    Loop
    ActiveRS.UpdateBatch
    Debug.Print "After Update " & ActiveRS.RecordCount
    '>>>>>>>>>>AT THIS POINT THE RECORDSET HAS 10 RECORDS<<<<<<<<
    ActiveTextStream.Close
    ' Tell the client your finished
    RaiseEvent ActiveFinish
    If Not ActiveRS Is Nothing Then Set ActiveRS = Nothing


    ' Check the database has been updated
    Set ActiveRS = objAXConn.GetRS(strSQL)
    Debug.Print "Later " & ActiveRS.RecordCount
    '>>>>>>>>>>NOW THE RECORDSET HAS 0 RECORDS AND WHEN CHECKED ONCE
    THE APPLICATION ENDS THE DB HAS NOT BEEN UPDATED<<<<<<<<

    If Not objAXConn Is Nothing Then Set objAXConn = Nothing
    Exit Sub
    ErrTrap:
    'if error tell caller
    Error_Occured Err.Number, Err.Description
    End Sub


  2. #2
    espin0za Guest

    Re: Recordset does not update in business object


    My guess is that something is happening to the connection object when it gets
    marshalled to the out of process activex exe. Is there any way you can make
    the business object an in process DLL?


    "Dave Barker" <dajb@globalnet.co.uk> wrote:
    >
    >I have a middle tier bis. object - I pass it the active connection then

    it
    >appears to update the database but when i check the database afterwards

    the
    >table has not been updated. If i use the exact same code within the client
    >application the database is updated correctly. I think i am missing something
    >in ADO but for the life of me I do not see what. Any help would be appreciated.
    >
    >The client code;
    >
    > ' Ref to the proActive clsActive class
    > Dim WithEvents MyActive As clsActive
    >
    > ' Call ActiveX EXE (the business object
    > Set MyActive = New clsActive
    > MyActive.GetActive fMainForm.ADOConnRef, ts
    >
    >The reference fMainForm.ADOConnRef is application reference to the active
    >connection which comes from an Active X DLL and ts is a TextStream.
    >
    >The business object code;
    >
    > Public Sub GetActive(ByRef ActiveConnRef As clsADOConn, _
    > ByRef ActiveTextStream As TextStream)
    > Dim lngR As Long
    > Dim strM As String * 9
    > Dim strP As String * 8
    > Const strSQL = "SELECT * FROM tblActive"
    >
    > On Error GoTo ErrTrap
    > ' Make the connection to the Main Application
    > ' and open the recordset.
    > Set objAXConn = ActiveConnRef
    >
    > Set ActiveRS = objAXConn.GetRS("DELETE * FROM tblActive")
    > Set ActiveRS = Nothing
    > Set ActiveRS = objAXConn.GetRS(strSQL)
    >
    > 'Takes a Active Connection and textstream then updates the db
    > 'Skip to First valid record
    > ActiveTextStream.Skip (279)
    > 'Start update
    >
    > Do While Not lngR = 10 'ActiveTextStream.AtEndOfStream
    > lngR = lngR + 1
    > ActiveRS.AddNew
    > ActiveRS.Fields(0) = lngR
    > ActiveRS.Fields(1) = ActiveTextStream.Read(9)
    > ActiveTextStream.Skip (161)
    > ActiveRS.Fields(2) = ActiveTextStream.Read(8)
    > ActiveTextStream.Skip (101)
    > 'Updates the calling program
    > RaiseEvent RecordCount(lngR)
    > Loop
    > ActiveRS.UpdateBatch
    > Debug.Print "After Update " & ActiveRS.RecordCount
    > '>>>>>>>>>>AT THIS POINT THE RECORDSET HAS 10 RECORDS<<<<<<<<
    > ActiveTextStream.Close
    > ' Tell the client your finished
    > RaiseEvent ActiveFinish
    > If Not ActiveRS Is Nothing Then Set ActiveRS = Nothing
    >
    >
    > ' Check the database has been updated
    > Set ActiveRS = objAXConn.GetRS(strSQL)
    > Debug.Print "Later " & ActiveRS.RecordCount
    > '>>>>>>>>>>NOW THE RECORDSET HAS 0 RECORDS AND WHEN CHECKED ONCE
    >THE APPLICATION ENDS THE DB HAS NOT BEEN UPDATED<<<<<<<<
    >
    > If Not objAXConn Is Nothing Then Set objAXConn = Nothing
    > Exit Sub
    >ErrTrap:
    > 'if error tell caller
    > Error_Occured Err.Number, Err.Description
    >End Sub
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center