ADO的RecordSet打开的次数有没有限制啊

olivia2046 2003-03-25 09:12:20
程序中有一function被反复调用,其中一句Set RecordSet=Connection.Execute(...)
在一台机子上执行没有问题,在另一台机子上执行总是在大概第50几次调用的时候说RecordSet不能被用来打开别的表了。不知有谁遇到过这个问题,还望指教
...全文
50 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
limit 2003-03-28
  • 打赏
  • 举报
回复
见你的另外一贴。
olivia2046 2003-03-28
  • 打赏
  • 举报
回复
感谢limit(梦锦) ,你说的方法似乎是管用的,原先出错的那行已经顺利执行了,但我还有一个问题,就是现在出错的地方变成了下面一处使用到connection对象的地方,
Set recordset = connection.OpenSchema(...)
这句中我如何替换掉connection对象呢,因为openschema似乎是connection对象才有的方法
还望再次指教
limit 2003-03-28
  • 打赏
  • 举报
回复
以下是msdn对2147467259错误的描述。

ERROR NOTES
Only the ADO Connection object has an errors collection. The observant reader will notice that a lightweight error handler is in effect for the RecordSet.Open examples. In the event of an error opening a RecordSet object, ADO should return the most explicit error from the OLEDB provider. Some common errors that can be encountered with the code above are described below.

If you omit (or there is an error in) the DefaultDir parameter in the connect string, you may receive the following error:


ADO Error # -2147467259
Description [Microsoft][ODBC Microsoft Access 97 Driver] '(unknown)'
isn't a valid path. Make sure that the path name is
spelled correctly and that you are connected to the server
on which the file resides.
Source Microsoft OLE DB Provider for ODBC Drivers


If there is an error in the Dbq parameter in the connect string, you may receive the following error:

ADO Error # -2147467259
Description [Microsoft][ODBC Microsoft Access 97 Driver] Couldn't find
file '(unknown)'.
Source Microsoft OLE DB Provider for ODBC Drivers


The previously listed errors will also populate the Connection.Errors collection with the following errors:

ADO Error # -2147467259
Description [Microsoft][ODBC Driver Manager] Driver's
SQLSetConnectAttr failed
Source Microsoft OLE DB Provider for ODBC Drivers

ADO Error # -2147467259
Description Login Failed
Source Microsoft OLE DB Provider for ODBC Drivers


Note that for each error, the ADO Error number is the same, in this case translating to 0x80004005, which is the generic E_FAIL error message. The underlying Component did not have a specific error number for the condition encountered, but useful information was never-the-less raised to ADO.

有可能是connection对象连接时间过长而断开了,试试用字符串而不是用connection

recordset.open sSQL, sConn
olivia2046 2003-03-26
  • 打赏
  • 举报
回复
而且这个问题在有的机子上不会出现,一开始我以为是没安装SP5的缘故,后来装上来问题还是如此。
olivia2046 2003-03-26
  • 打赏
  • 举报
回复
还是不行,总是报run-time error '-2147467259(80004005)':不能再打开其他表了
我按出错信息搜索,2147467259对应的是unspecified error
olivia2046 2003-03-26
  • 打赏
  • 举报
回复
UP!
lxcc 2003-03-25
  • 打赏
  • 举报
回复
在你的rs.open执行之前先执行上述语句
lxcc 2003-03-25
  • 打赏
  • 举报
回复
if rs.state=adStateOpen then rs.close
lihonggen0 2003-03-25
  • 打赏
  • 举报
回复
'业务员合同
With Rs_Jc_Shhy_Csb
If .State = adStateOpen Then
.Close
End If
.ActiveConnection = adoCN
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockBatchOptimistic
.Source = "SELECT * FROM Jc_Shhy_Csb WHERE hth='" & W_Jc_Shhy.Text1(0).Text & "'"
.Open
End With
qqqdong 2003-03-25
  • 打赏
  • 举报
回复
这样:
Set RecordSet = New ADODB.RecordSet
recordset.open .....
....
recordset.close
set recordset = nothing
zsgzsgzsg 2003-03-25
  • 打赏
  • 举报
回复
将局部变量RecordSet换成别的变量名,是不是相互调用时,其它过程中也有RecordSet变量而相互冲突。
olivia2046 2003-03-25
  • 打赏
  • 举报
回复
那么我程序中应该是已经关闭了RecordSet的吧。那如何解决我的问题呢
zsgzsgzsg 2003-03-25
  • 打赏
  • 举报
回复
RecordSet定义的是局部变量,在函数执行完一次后变量是自动关闭,但RecordSet与数据库的连接不会断开,并且RecordSet占用的内存也不会释放。
RecordSet打开一次,就要关闭一次。
olivia2046 2003-03-25
  • 打赏
  • 举报
回复
UP
olivia2046 2003-03-25
  • 打赏
  • 举报
回复
qqqdong和lxcc的方法都试过了,不行,而且我的RecordSet定义的是局部变量,在函数执行完一次后应该是自动关闭RecordSet的吧。

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧