CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2012
    Posts
    3

    Angry Concurrency/Consistency Managing in VB6

    Dear Pros,

    Im a Visual Basic Programmer with experience of about 12 years. I do my application using VB as front end and Oracle as back end. However, i had never deployed in a highly concurrent enivironment where many users use the application at the same time. I am in the process of implementing but have got challenges as the application keep on throwing errors and not completing the transactions. The following are the Errors that are frequently thrown which i suspect are as a result of Concurrency request:

    "cannot update row as the data in the database has changed"
    "cannot delete row as data in the database has changed"


    This is how im connecting to my DB

    If RsCoin.State = 1 Then
    RsCoin.Close
    End If
    CmdCoin = "SELECT * FROM COINAGER WHERE ACCNO='" & CoinSt & "'"
    RsCoin.Open CmdCoin, ConACExp, adOpenStatic, adLockOptimistic

    RsCoin is a recordset

    Can somebody assist me how to solve this problem?

  2. #2
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Re: Concurrency/Consistency Managing in VB6

    where are you getting the following error ?
    "cannot update row as the data in the database has changed"
    "cannot delete row as data in the database has changed"

  3. #3
    Join Date
    Jul 2012
    Posts
    3

    Red face Re: Concurrency/Consistency Managing in VB6

    I am getting the error at a point of updating.

    RsCoin.update

    Soo many users are updating that table. its a banking environment.

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Concurrency/Consistency Managing in VB6

    Can you post the Sub where the Code that error occurs... And Please use Code Tags...
    [code] Your Code [/code]...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #5
    Join Date
    Jul 2012
    Posts
    3

    Re: Concurrency/Consistency Managing in VB6

    Code:
    Public Sub Create_TransactionID()
    'On Error Resume Next
    Dim SavedDate, CurrDateNo
        'Creating Absence ID
        If RsRef.EOF = False Then
           RsRef.MoveLast
           SavedAbid = RsRef!TRANSREF
           SavedDate = RsRef!TRANSREF
           
           RsRef.Delete 'So that we only have one serial at ago 'Added on 12/11/07
           RsRef.Requery
           RsRef.AddNew
           DateSt = Now
           
           If Len(SavedDate) = 8 Then
              SavedDate = Mid(SavedAbid, 1, 8)
           Else
             SavedDate = SavedDate
           End If
      
           Call Convert_DateTo_Number
           CurrDateNo = Mwaka & Mwezi & Enyanga
           
        '   If SavedDate = CurrDateNo Then 'silenced 15032010
           If Left(SavedAbid, 8) = CurrDateNo Then
              Katikati = Mid(SavedAbid, 9, 1000)
              Katikati = Katikati + 1
            Else
              Katikati = "0"
           End If
                  
           Absid = Mwaka & Mwezi & Enyanga & Katikati
           RsRef!TRANSREF = Absid
           RsRef.Update 'Here error occurs
           
           Else
           DabID.AddNew
           Katikati = "0"
           DateSt = Now
           Call Convert_DateTo_Number
           Absid = Mwaka & Mwezi & Enyanga & Katikati
           RsRef!TRANSREF = Absid
           RsRef.Update
           
        End If
        
        If TranT = "Deposit" Then
           Absid = "DP" & Absid
          Else
           If TranT = "Withdrawal" Then
              Absid = "WR" & Absid
            Else
              If TranT = "OC" Then
                 Absid = "OC" & Absid
               Else
                 If SharesT = True Then
                    Absid = "SH" & Absid
                  Else
                   If Loan = True Then
                      Absid = "LN" & Absid
                    Else
                     If MpesaT = True Then
                        Absid = "MP" & Absid
                      Else
                       If IntProc = True Then
                          Absid = "IN" & Absid
                        If Treasury = True Then
                           Absid = "TR" & Absid
                        End If
                       End If
                     End If
                   End If
                 End If
              End If
            End If
        End If
    End Sub
    Last edited by GremlinSA; July 23rd, 2012 at 09:34 AM. Reason: PLEASE USE CODE TAGS..

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Concurrency/Consistency Managing in VB6

    In a multi user environment you should move away from the rs.update and use a sql query to insert, update or delete instead.

    I think that should slove the issue, I ran into something similar in the past where I had heavy traffic inserting data and the SQL Insert was flawless where rs.update failed with an error often.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured