BUG: SQLOLEDB May Spawn Additional Connection For Action Query

ID: Q191268

The information in this article applies to:

SYMPTOMS

If you have a server-side cursor open and execute an action query, the SQL Server OLE DB Provider treats an action query as if it returned data in a forward-only, read-only cursor and isolates that query on its own connection. This connection is created solely for the action query and is closed immediately after executing the query.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

If you do not have a server-side cursor currently opened on the ActiveX Data Objects (ADO) connection object, the SQL Server OLE DB provider does not create a second connection to the database.

Use SQL Server's SQL Trace utility to see that the following code establishes a second connection to the database to perform the action query. Modify the connection string to connect to your SQL Server database.

Here is the code:

   Dim cnPubs As New ADODB.Connection
   Dim rsKeyset As New ADODB.Recordset
   Dim strConn As String
   Dim strSQL As String
   Dim strActionQuery As String

   strConn = "Provider=SQLOLEDB;Data Source=MyServer;Initial Catalog=pubs;"
   strSQL = "SELECT * FROM Authors"
   strActionQuery = "DELETE FROM Authors WHERE 1 = 0"

   cnPubs.Open strConn, "sa", ""
   rsKeyset.Open strSQL, cnPubs, adOpenKeyset, adLockReadOnly, adCmdText
   cnPubs.Execute CommandText:=strActionQuery, Options:=adExecuteNoRecords

Additional query words: kbADO200bug kbOLEDB200bug kbADO200
Version           : WINDOWS:2.0,5.0,6.0,97
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: August 13, 1998