The database engine could not lock table

ClOuD_Za
ClOuD_Za used Ask the Experts™
on
Hi

I have a VB6 Application which contains code like this ...

IN A BUTTON :
Dim db As ADODB.Connection

IN "ExecuteDB" FUNCTION
Public Function ExecuteDB(ByVal QueryStr As String, ByRef db As ADODB.Connection) As ADODB.Recordset
    On Error GoTo ErrorHandling:
    Dim rs As New ADODB.Recordset
    rs.Open QueryStr, db, 1, 3
    Set ExecuteDB = rs
    Exit Function
ErrorHandling:
    MsgBox ("ERROR : ExecuteDB Error " & vbNewLine & vbNewLine & Err.Number & " : " & Err.Description & vbNewLine & vbNewLine & "PLEASE CONTACT STAFF")
    Err.Clear
    MsgBox QueryStr
    Success = False
    Set ExecuteDB = Nothing
End Function

IN A METHOD THAT CALL "ExecuteDB" :
Dim rs As New ADODB.Recordset
Set rs = ExecuteDB(tmpQueryStr, db) <<< This line is to check if data exist in TABLE via tmpQueryStr

LATER IN THE METHOD :
ExecuteDB(IncrementStr, db) <<< This line is to INSERT into TABLE if data not exist OR UPDATE if data exist

After I pressed the button. "The database engine could not lock table because it is already in use by another person or process"

Please Help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
If found solution myself.

It's the "LockType" in Recordset.Open Method.

just set it to -1 or leave it blank.

Now I need to delete this question.

thank you any way

Author

Commented:
I'd like to share this solution with other.

If I delete this question. the solution would be lost.

So I accept my post as solution . and refund my point.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial