Report Date: 2002/9chin a i t p oe er . co mNRaoA
Prepared by: 郑 昀
Article last modified on 2002-9chin a i t p oe er . co mNRaoA
The information in this article applies to:
ü Microsoft SQL Server 2000,7.0
ü Microsoft ADO 2.5
数据库服务器:Microsoft SQL Server 2000以及7.0;
数据库服务器补丁:Microsoft SQL Server 2000 ServicePack1;
ADO名称:Microsoft Data Access - ActiveX Data Objects 2.5 Type Library
ADO版本:2.61.7326.0
执行下面的VB代码时,我们的开发人员产生了疑问:
cnn.Open "Provider=SQLOLEDB.1;
Persist Security Info=False;User ID=sa;
Initial Catalog=freemail;Data Source=svr;ConnectionTimeout=10", "", "", -1
sql = "select * from users"
Set rs = cnn.Execute(sql)
Set rs2 = cnn.Execute(sql)
Set rs3 = cnn.Execute(sql)
执行这段代码时,在SQL Server Profiler中看到,每个sql语句执行之前都会有一个Audit Login事件。而Audit Login事件的解释是:“收集自跟踪启动后发生的所有新的连接事件,例如客户端请求连接到运行 Microsoft® SQL Server™ 实例的服务器”。也就是说,用Connection对象连接SQL Server之后,每次执行sql语句时仍然会重新建立一次连接,即使用的是同一个Connection?!
建立连接的事件探查记录(按时间顺序)为:chin a i t p oe er . co mNRaoA
EventClass
Text Data
TraceStart
Audit Login
(第一次连接)
-- network protocol: LPC
set quoted_identifier on
set implicit_transactions off
set cursor_close_on_commit off