FIX: SQLOLEDB Resends Prepared Commands with Client Cursors

This article was previously published under Q238355
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 55798 (SQLBUG_70)
When using the SQLOLEDB provider with client side cursors and prepared statements, the performance is slower than with SQL Server 6.5 and ODBC.When tracing the SQL statements sent by the client application with SQL Server Profiler, a sequence of statements similar to the following can be observed:
SQL Server 7.0
sp_prepare @P1 output, N'@P1 varchar(40)', N'select au_fname, au_lname   from pubs..authors where au_lname like @P1', 1 select @P1sp_unprepare 1sp_executesql N'select au_fname,au_lname from pubs..authors   where au_lname like @P1', N'@P1 nvarchar(2)', N'M%'					

SQL Server 6.5
create proc #oledbsa1(@P1 varchar(40)) as select au_fname,au_lname<BR/>   from pubs..authors where au_lname like @P1select au_fname,au_lname from pubs..authors where au_lname like 'M%'					
As shown in the SQL trace, under these circumstances the SQLOLEDB provider first prepares the statement but sends it again to get the rows for the client side cursor.
To work around this problem, try either of the following:

  • Do not use prepared statements.

  • Use server based cursors.
Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 2 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
254561 INF: How to Obtain Service Pack 2 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.

Article ID: 238355 - Last Review: 02/21/2014 00:37:35 - Revision: 3.1

Microsoft SQL Server 7.0 Standard Edition, Microsoft Data Access Components 2.1

  • kbnosurvey kbarchive kbbug kbfix KB238355