It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Error handling a database error, Help!

Moderator: dafunkymunky

Error handling a database error, Help!

Postby Mooe on Sun Aug 24, 2008 10:32 pm

Hey,

I have a problem thats stumped me for the last week, and if anyone would know what to do it would be you guys :) . Anyway, I have a program that works fine, except when someone else using the program is using the database at the same time. When that happens the program error's out saying "the database has been placed in a state by user....". I tried error trapping to just get the error to go away and have it loop until it could access the database, but that didn't work :( .

Heres the code I'm working with:

Code: Select all
Private Sub Timer1_Timer()
On Error GoTo ErrorHandler
Dim orig2 As String
Dim orig3 As Long





Adodc4.RecordSource = "SELECT * FROM tRegister Where cdeRegister='B'"
            Adodc4.Refresh
            Adodc4.Recordset.Requery
           
            orig2 = Adodc4.Recordset.Fields("cdeLastTransaction")
            orig3 = Mid(orig2, 2, Len(orig2) - 2)
            If (orig3 <> orig1) Then
                Adodc1.RecordSource = "SELECT * FROM tSaleTransactions Where cdeTrans='B" & orig3 & "'"
                Adodc1.Refresh
               
                If (Adodc1.Recordset.RecordCount = 0) Then
                Do Until Adodc1.Recordset.RecordCount = 1
               
                Adodc1.RecordSource = "SELECT * FROM tSaleTransactions Where cdeTrans='B" & orig3 & "'"
                Adodc1.Refresh
             
                Loop
                End If
               
                If (Adodc1.Recordset.RecordCount <> 0) Then
               
               
                    If (Adodc1.Recordset.Fields("cdeCustCode") <> Empty) Then
                   
               
                            If Adodc1.Recordset.Fields("cdeCustCode") >= 100000000 Then
                                Adodc2.RecordSource = "SELECT * FROM acc Where AccountNumber='" & Adodc1.Recordset.Fields("cdeCustCode") & "'"
                                Adodc2.Refresh
                               
                                Call Command1_Click
                                Call Command2_Click
                             


                            End If
               
                    End If
                   
            End If
        End If
       
       
       
       
       
       
       
       
 
       
       Adodc4.RecordSource = "SELECT * FROM tRegister Where cdeRegister='B'"
          Adodc4.Refresh
           Adodc4.Recordset.Requery
     orig = Adodc4.Recordset.Fields("cdeLastTransaction")
            orig1 = Mid(orig, 2, Len(orig) - 2)

Exit Sub

ErrorHandler:
    Call Timer1_timer
   
End Sub




This works fine, except the program pops up with the "the database has been placed in a state..." error, but once you click ok the program starts the loop over and everything is fine.

How do I get the error to not show up??

Thanks :)
Mooe
 
Posts: 2
Joined: Sun Aug 24, 2008 10:26 pm

Postby sendtoanurag on Mon Aug 25, 2008 5:35 am

Ok CLose the programme and then chk if there is an .ldb file there with the database name.
If it exists then delete it.
sendtoanurag
 
Posts: 29
Joined: Tue Mar 18, 2008 2:51 pm

Postby Mooe on Mon Aug 25, 2008 11:57 am

This problem only happens once every few hours, and once they click "ok" everything is straitened out. The LDB file goes away after the program is done with the DB, it's just that I have the program waiting it's turn. If I could stop the error from showing up everything would be great.

Thanks for the help tho.
Mooe
 
Posts: 2
Joined: Sun Aug 24, 2008 10:26 pm


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests