PRB: ODBCDirect Query Causes Error 3667 (177516)



The information in this article applies to:

  • Microsoft Visual Basic Learning Edition for Windows 5.0
  • Microsoft Visual Basic Learning Edition for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q177516

SYMPTOMS

Running a query or manipulating a recordset in an ODBCDirect workspace causes the following error to occur:
"A different operation is preventing this operation from being executed, runtime error 3667."

CAUSE

This error can be caused by trying to run more than one asynchronous operation at a time on the same connection object or performing other Data Access Object (DAO) operations (such as recordset manipulation) on the same connection object while an asynchronous query runs.

RESOLUTION

To run multiple asynchronous queries on the same connection object, you must first test the value of the StillExecuting property to determine whether you can start the next asynchronous operation. To run multiple asynchronous queries in parallel, you must create separate connection objects and run each asynchronous query on its own connection object.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a Visual Basic standard .exe file. By default this places a Form in the project. Under Project References select "Microsoft DAO 3.5 Object Library."
  2. In the General Declarations section of the Form1, place the following code:
          Dim wks As Workspace
          Dim cn As Connection
          Dim recset As Recordset
          Dim SQLStuff As String
    
    						
  3. In the Form_Load event place the following code. This code assumes that you have a DSN that connects to the sample pubs database in SQL Server and that you have the appropriate permissions and UserId and Password values.
          SQLStuff = "ODBC;DSN=PubsDSN;UID=UserName;PWD=StrongPassword"
          Set wks = CreateWorkspace("", "admin", "", dbUseODBC)
          Set cn = wks.OpenConnection("", dbDriverNoPrompt, False, SQLStuff)
    
    						
  4. Place a command button on the form by adding the following code to the Command1_Click event:
          SQLStuff = "UPDATE employee SET job_lvl = job_lvl + job_lvl * .1"
          cn.Execute SQLStuff, dbRunAsync
          Set recset = cn.OpenRecordset("SELECT * FROM authors", dbOpenDynamic,
             dbRunAsync, dbOptimisticValue)
    
    						
Note that the connection execute method is still using the connection when the openrecordset method is used. This is what causes the error to occur.

REFERENCES

For more information query on stillexecuting in the help file or in "Books On Line."

Modification Type:MajorLast Reviewed:11/3/2003
Keywords:kbprb KB177516