possibly need a way of error trapping

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • miroku800
    New Member
    • Mar 2007
    • 21

    #16
    Originally posted by pureenhanoi
    Mark-file is abit diffrent from lock-file. If lock-file exist, (C) will skip update (because (A) havent finished sending data yet)..
    That would be fine if it would just skip the update cos it will try and update as soon as someone looks at another score which is very frequently
    The problem is it won't skip if it can't update it just 'bombs'
    all I need to know is how to make it skip on finding the lock file

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #17
      Originally posted by miroku800
      That would be fine if it would just skip the update cos it will try and update as soon as someone looks at another score which is very frequently
      The problem is it won't skip if it can't update it just 'bombs'
      all I need to know is how to make it skip on finding the lock file
      For that, I think we will need more detail on what it is doing, and how, and what version of VB it is written in.

      Can we see the code which is bombing? It might be as simple as doing something like On Error Resume Next and checking Err.Number to see whether the copy worked.

      Comment

      • pureenhanoi
        New Member
        • Mar 2007
        • 175

        #18
        Originally posted by miroku800
        That would be fine if it would just skip the update cos it will try and update as soon as someone looks at another score which is very frequently
        The problem is it won't skip if it can't update it just 'bombs'
        all I need to know is how to make it skip on finding the lock file
        Now, say something about skip updating:
        the old process maybe like:
        [code=vb]
        Private Sub cmdShowScore_Cl ick()
        score = getScoreFromDat aBase()
        Display score
        End Sub
        [/code]
        the new process must be:
        [code=vb]
        Private Sub cmdShowScore_Cl ick()
        If isExistingMarkF ile Then
        call updatingDataBas e()
        End If
        score = getScoreFromDat aBase()
        Display score
        Ens Sub
        Private Function isExistingMarkF ile() As Boolean
        Dim fileName As String
        fileName = "path to markfile"
        If Dir(fileName)<> "" Then
        isExistingMarkF ile = True
        Else
        isExistingMarkF ile = False
        End If
        End Function
        Private Sub updatingDataBas e()
        'use each diffent file name for each time need updating
        If currDbname = "(C)\db2.md b" Then
        currDbName = "(C)\db1.md b" 'here is global varriable, use to store current database file name
        Else
        currDbName = "(C)\db2.md b"
        End If
        FileCopy "(B)\db1.md b" currDbName 'overwrite old file if you need
        'close current connection
        con1.Close
        'refer connection to new database
        con1.Connection String ="Provider=Micr osoft.Jet.OLEDB .4.0; Data Source='" & currDbname & "'"
        're-open the connection
        con1.Open
        'remove the mark-file
        Call Kill "path to mark-file"
        End Sub
        [/code]
        Last edited by pureenhanoi; Aug 20 '07, 01:49 AM. Reason: add = vb to Code tag

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #19
          Originally posted by pureenhanoi
          ...the new process must be:
          [code=vb]
          Private Sub cmdShowScore_Cl ick()
          If isExistingMarkF ile Then
          call updatingDataBas e()
          End If
          score = getScoreFromDat aBase()
          ...[/CODE]
          I disagree, not in principle, but with the way it's implemented. This sort of thing should be handled in the getScoreFromDat aBase routine, not the user interface. In other words, you shouldn't have to check for the "mark file" in each button-click routine.

          Comment

          • pureenhanoi
            New Member
            • Mar 2007
            • 175

            #20
            Originally posted by Killer42
            I disagree, not in principle, but with the way it's implemented. This sort of thing should be handled in the getScoreFromDat aBase routine, not the user interface. In other words, you shouldn't have to check for the "mark file" in each button-click routine.
            Let see, why did you need checking for mark-fle in getScoreFromDat abase()? Each time user hit the button, we call getScoreFromDat aBase() one time. That mean, if i placed the check function outside or inside the getScoreFromDat abase(), the check function will be called each time for the hit button event.
            If you have another way to reduce the frequently of check-function, maybe its better to place check-function inside getScoreFromDat abase().
            But thats not the problem.You can place the check-function anywhere you like, but you should check for newer data each time user need display data, or the data will be old.

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #21
              Originally posted by pureenhanoi
              ... But thats not the problem.You can place the check-function anywhere you like, but you should check for newer data each time user need display data, or the data will be old.
              That's precisely my point. It should be "encapsulat ed" within the database lookup function, as a standard part of the process. Not something that the caller has to remember to check before calling the lookup.

              Comment

              Working...