防止ADO连接SQL Server时的隐式连接[6]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 zhengyun_ustc 的 blog

audit logout

 

audit logout

 

tracestop

 

 

而如果每句cnn.execute后面加上rs.close()则每个execute之前不会有audit login事件,而是连续的3sql:stmtstarting事件。

这样频繁建立物理连接,是否会影响性能?照例说应该重用同一个连接才对呀?

cause:

这种情况叫做隐式登录。

set一个ado.recordset对象接收ado.connection.execute返回的记录集时,就会出现隐式登录,再次和数据库服务器建立一次物理连接,而且这个连接还没有办法重用,也不能池化。

这个的原因是:

because the sql server ole db provider doesn't permit more than one set of results to be pending on a connection where the results are being returned by means of a forward-only, read-only (default-resultset) cursor, the provider needs to create an additional sql server connection to execute a second command on the connection. the provider will only do this implicitly if the data source property dbprop_multipleconnections is set to variant_true.

 

可以参考微软的kb文档:

http://support.microsoft.com/default.aspx?scid=kb;en-gb;q271128&gssnb=1

本文关键:ado sql server connection recordset command
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top