Recordset无缘无故关闭 [英] Recordset closes for no reason

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

问题描述




我正在使用vb.net和sql2000。

我正在运行一个使用udl连接数据库的sql语句。

通过一个子程序,对udl的cn执行了几个sql语句,我只是重用rs来保存下一个结果集。


我的问题是通过一些声明,这工作正常 - 我可以使用与rs并设置一个循环来循环rs以确认返回的数据。但当我到达其中一个(它们是相同的,除了传递的sql语句)rs意外关闭,我无法看到其中的数据,因此它返回一个错误,表明rs已关闭。


任何想法为什么会这样做?我的代码中的任何地方都没有告诉我太多了。


干杯

亚当

解决方案

您应该在VB.NET中使用数据集而不是记录集。


如果你使用ADO而不是ADO.NET使用记录集,那么请验证你正在使用的光标类型。


- -

Gerry O''Brien [MVP]

Visual Basic .NET(VB.NET)


Adam Maltby <广告*** @ frfl.co.uk>在留言新闻中写道:O%****************** @ TK2MSFTNGP11.phx.gbl ...




我正在使用vb.net和sql2000。

我正在运行一个使用udl连接数据库的sql语句。

Throuhg one sub,几个sql语句是针对udl的cn执行的,我只是重用rs来保存下一个结果集。


我的问题是通过一些语句可以正常工作 - 我可以使用With rs并设置一个循环来循环rs以确认返回的数据。但当我到达其中一个(它们是相同的,除了传递的sql语句)rs意外关闭,我无法看到其中的数据,因此它返回一个错误,表明rs已关闭。


任何想法为什么会这样做?我在代码中的任何地方都没有告诉你太多了。


干杯

亚当


Gerry,

您应该使用的数据集不是VB.NET中的记录集。




升级使用那么,这对我来说听起来有点像你说微软的产品不行,你想这么说吗?


Cor


Adam,


如果没有代码的部分,这是我无法回答的问题

谈论。


原谅我,我不知道,不过什么是UDL。


Cor

Hi,

I am using vb.net and sql2000.
I am running a sql statement using a udl to connect to the database.
Throuhg one sub, several sql statements are executed against the udl''s cn and I just reuse the rs to hold the next result set.

My problem is that through a few statements this works fine - I can use "With rs" and set up a cycle to loop through the rs to confirm data returned. But when I reach one of them (they are the same except for the sql statement passed) the rs closes unexpectedly and I cannot see the data within it hence it then returns an error stating the rs is closed.

Any ideas why it might be doing this? I am not telling the rs too clsoe anywhere in my code (yet).

Cheers
Adam

解决方案

You should be using a dataset not a recordset in VB.NET.

If you are using a recordset though using ADO and not ADO.NET, then verify what type of cursor you are using.

--
Gerry O''Brien [MVP]
Visual Basic .NET(VB.NET)


"Adam Maltby" <ad***@frfl.co.uk> wrote in message news:O%******************@TK2MSFTNGP11.phx.gbl...
Hi,

I am using vb.net and sql2000.
I am running a sql statement using a udl to connect to the database.
Throuhg one sub, several sql statements are executed against the udl''s cn and I just reuse the rs to hold the next result set.

My problem is that through a few statements this works fine - I can use "With rs" and set up a cycle to loop through the rs to confirm data returned. But when I reach one of them (they are the same except for the sql statement passed) the rs closes unexpectedly and I cannot see the data within it hence it then returns an error stating the rs is closed.

Any ideas why it might be doing this? I am not telling the rs too clsoe anywhere in my code (yet).

Cheers
Adam


Gerry,

You should be using a dataset not a recordset in VB.NET.



The upgrade uses that, so this sounds for me a little bit that you say that
the Microsoft product is not OK, do you want to say that?

Cor


Adam,

This is in my eyes impossible to answer without the part of code you are
talking about.

And forgive me tha I do not know it, however what is an UDL .

Cor


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

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