Microsoft KB Archive/177516

= PRB: ODBCDirect Query Causes Error 3667 =

Article ID: 177516

Article Last Modified on 11/3/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



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.



Steps to Reproduce the Behavior
 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."  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

  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)

  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.

<div class="references_section">