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

olivia2046 2003-03-25 09:12:20
程序中有一function被反复调用,其中一句Set RecordSet=Connection.Execute(...)
在一台机子上执行没有问题,在另一台机子上执行总是在大概第50几次调用的时候说RecordSet不能被用来打开别的表了。不知有谁遇到过这个问题,还望指教
...全文
21 点赞 收藏 15
写回复
15 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
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的吧。
回复
相关推荐
发帖

1187

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-03-25 09:12
社区公告
暂无公告