关闭由Execute创建的ADO Recordset [英] Closing ADO Recordset created by Execute

查看:73
本文介绍了关闭由Execute创建的ADO Recordset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打开ADO Recordset时,我将其关闭。但是,似乎有可能

以这种方式打开Recordset会有所不同:


Dim rL As ADODB.Recordset

设置rL =新ADODB.Recordset

src =" SELECT Count(*)FROM reviewer INNER JOIN pp_officer" &安培; _

" ON reviewer.reviewer_id = pp_officer.ppo_rev_id" &安培; _

" WHERE rev_login =''EllisonL''"

设置rL = CurrentProject.Connection.Execute(src,,adCmdText)

c = rL.Fields(0)

rL.Close


在这种类型的Recordset中,仍然需要Close语句 -

毕竟没有明确的开放?


-

Darryl Kerkeslager

When I open an ADO Recordset, I close it. However, it seems that there may
be some difference in this manner of opening a Recordset:

Dim rL As ADODB.Recordset
Set rL = New ADODB.Recordset

src = "SELECT Count(*) FROM reviewer INNER JOIN pp_officer " & _
"ON reviewer.reviewer_id = pp_officer.ppo_rev_id " & _
"WHERE rev_login = ''EllisonL''"
Set rL = CurrentProject.Connection.Execute(src, , adCmdText)
c = rL.Fields(0)
rL.Close

In this type of Recordset, is the Close statement still necessary - there
is, after all, no explicit Open?

--
Darryl Kerkeslager

推荐答案

No。

No.




" Darryl Kerkeslager" <柯********* @ comcast.net>在消息中写道

新闻:9Z ****************************** @ comcast.com。 ..

"Darryl Kerkeslager" <ke*********@comcast.net> wrote in message
news:9Z******************************@comcast.com. ..
当我打开ADO Recordset时,我关闭它。但是,看起来
在打开Recordset时可能会有一些差异:

Dim rL As ADODB.Recordset
设置rL =新ADODB.Recordset
src =" SELECT Count(*)FROM reviewer INNER JOIN pp_officer" &安培; _
" ON reviewer.reviewer_id = pp_officer.ppo_rev_id" &安培; _
  WHERE rev_login =''EllisonL''"
设置rL = CurrentProject.Connection.Execute(src ,, adCmdText)
c = rL.Fields(0)
rL.Close

在这种类型的Recordset中,仍然需要Close语句 - 毕竟,
没有明确的Open?

- < br> Darryl Kerkeslager
When I open an ADO Recordset, I close it. However, it seems that there may be some difference in this manner of opening a Recordset:

Dim rL As ADODB.Recordset
Set rL = New ADODB.Recordset

src = "SELECT Count(*) FROM reviewer INNER JOIN pp_officer " & _
"ON reviewer.reviewer_id = pp_officer.ppo_rev_id " & _
"WHERE rev_login = ''EllisonL''"
Set rL = CurrentProject.Connection.Execute(src, , adCmdText)
c = rL.Fields(0)
rL.Close

In this type of Recordset, is the Close statement still necessary - there
is, after all, no explicit Open?

--
Darryl Kerkeslager




如果查询返回行,则会创建记录集对象。非常肯定

应该关闭。


兰迪



If the query returns rows a recordset object is created. It very definitely
should be closed.

Randy



" Randy Harris" < RA *** @ SpamFree.com>在消息中写道

新闻:Rz **************** @ newssvr30.news.prodigy.com ...

"Randy Harris" <ra***@SpamFree.com> wrote in message
news:Rz****************@newssvr30.news.prodigy.com ...
< br>Darryl Kerkeslager <柯********* @ comcast.net>在消息中写道
新闻:9Z ****************************** @ comcast.com。 ..

"Darryl Kerkeslager" <ke*********@comcast.net> wrote in message
news:9Z******************************@comcast.com. ..
当我打开ADO Recordset时,我关闭它。但是,似乎
When I open an ADO Recordset, I close it. However, it seems that there may
在这种打开Recordset的方式上有所不同:

Dim rL As ADODB.Recordset
设置rL =新的ADODB。记录集

src =" SELECT Count(*)FROM reviewer INNER JOIN pp_officer" &安培; _
" ON reviewer.reviewer_id = pp_officer.ppo_rev_id" &安培; _
  WHERE rev_login =''EllisonL''"
设置rL = CurrentProject.Connection.Execute(src ,, adCmdText)
c = rL.Fields(0)
rL.Close

在这种类型的Recordset中,仍然需要Close语句 - 毕竟,
没有明确的Open?

- < br> Darryl Kerkeslager
be some difference in this manner of opening a Recordset:

Dim rL As ADODB.Recordset
Set rL = New ADODB.Recordset

src = "SELECT Count(*) FROM reviewer INNER JOIN pp_officer " & _
"ON reviewer.reviewer_id = pp_officer.ppo_rev_id " & _
"WHERE rev_login = ''EllisonL''"
Set rL = CurrentProject.Connection.Execute(src, , adCmdText)
c = rL.Fields(0)
rL.Close

In this type of Recordset, is the Close statement still necessary - there is, after all, no explicit Open?

--
Darryl Kerkeslager



如果查询返回行,则会创建记录集对象。非常



If the query returns rows a recordset object is created. It very



绝对应该关闭。

Randy


definitely should be closed.

Randy




BTW-如果你想在不创建

记录集对象的情况下检索数据(例如计数),可以使用GetString方法。


recCount = CurrentProject.Connection.Execute(src ).GetString



BTW- If you want to retrieve data (such as a count) without creating a
recordset object, you can use the GetString method.

recCount = CurrentProject.Connection.Execute(src).GetString


这篇关于关闭由Execute创建的ADO Recordset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆