Ado.Net RecordSet 成员等效吗?

发布于 2024-09-29 09:01:13 字数 596 浏览 10 评论 0原文

我目前正在将依赖于 ADO 的 Vb6 程序重写为带有 ADO.NET 的 C# 程序。我在原始代码中的几个地方遇到过这样的问题:

Dim rs As New Recordset
rs.CacheSize = 500
Call rs.Open(sSql, cnMeta, adOpenForwardOnly, adLockReadOnly)

Is there a equals (or even need for a equal to) to ADO.RecordSet.CacheSize in Ado.Net? (这些大写?)我很高兴接受“ADO.NET”为您解决这个问题(事实上,非常很高兴接受这一点)。我的问题是,在这次迁移之前我没有 ADO 经验,所以我不确定是否会遗漏一些微妙之处。

我是否正确理解 adOpenForwardOnly 和 adLockReadOnly 是使 RecordSet 的行为类似于 SqlDataReader 的[编辑]方式[/编辑]?如果是这样,那么我唯一真正的问题是我是否需要增加 Ado.Net 缓存,或者是否默认处理该缓存。

如果这是一个重复的问题,我真的很抱歉。我似乎无法在 SO 或 msdn 上找到这个。

I'm currently re-writing a Vb6 program relying on ADO into C# w/ ADO.NET. I've run into several places in the original code with stuff like this:

Dim rs As New Recordset
rs.CacheSize = 500
Call rs.Open(sSql, cnMeta, adOpenForwardOnly, adLockReadOnly)

Is there an equivalent (or even a need for an equivalent) to ADO.RecordSet.CacheSize in Ado.Net? (Capitalization on those?) I'm happy to accept "ADO.NET" takes care of that for you (very happy to accept that, in fact). My problem is that that I had no ADO experience before this migration so I'm not sure if there's subtleties I'd be missing.

Do I understand correctly that adOpenForwardOnly and adLockReadOnly are the [EDIT] way to make RecordSet behave like SqlDataReader already does [/EDIT]? If so, then my only real question is whether or not I need to make Ado.Net cache more or if that gets handled by default.

I'm really sorry if this is a repeated question. I can't seem to find this on S.O. or msdn though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苍风燃霜 2024-10-06 09:01:14

CacheSize 属性控制记录集读入其内部缓冲区的记录数量。 ADO.NET 中没有等效的属性,因为它不是以相同的方式缓冲的。所以,你可以把它忽略掉。

我的理解正确吗
adOpenForwardOnly 和 adLockReadOnly
SqlDataReader 是默认值吗?

是的。嗯,这不是默认设置,而是数据读取器工作的唯一方式。对于使用 RecordSet 的任何其他方式,您将使用其他类,例如 DataSetSqlDataAdapter

The CacheSize property controls how many records the recordset reads into it's internal buffer. There is no equivalent property in ADO.NET, because it's not buffered in the same way. So, you can just leave that out.

Do I understand correctly that
adOpenForwardOnly and adLockReadOnly
are the defaults for SqlDataReader?

Yes. Well, it's not the default, but rather the only way that the data reader ever works. For any other way that a RecordSet is used, you would use other classes, like DataSet and SqlDataAdapter.

小耗子 2024-10-06 09:01:14

这篇文章可能会有所帮助:

http://www.devnewsgroups.net /adonet/t55360-paging-recordsets-ado-net.aspx

还有一个指向 MSDN CacheSize 主题的快速链接:

http://msdn.microsoft.com/en-us/library/ms675871%28VS.85%29.aspx

但是,我的建议是,的方法是熟悉 .NET 3.5 中引入的 Linq-to-SQL。当我在 LINQ(基于 ADO.NET 构建并且对程序员非常友好)方面拥有丰富的经验时,我不想帮助建议您用 ADO.NET 替换过时的 VB6 功能 - 阅读此处,在许多地方,看看有什么区别。

This post may help:

http://www.devnewsgroups.net/adonet/t55360-paging-recordsets-ado-net.aspx

Also a quick link to the MSDN CacheSize topic:

http://msdn.microsoft.com/en-us/library/ms675871%28VS.85%29.aspx

My recommendation, however, would be to familiarize yourself with Linq-to-SQL, which was introduced in .NET 3.5. I'd rather not help recommend you to replace outdated VB6 functionality with ADO.NET, when I have had great experiences with LINQ (which is built on ADO.NET and is very programmer-friendly) - read here, among many places, to see what the differences are.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文