数据集或datareader [英] Dataset or datareader

查看:63
本文介绍了数据集或datareader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一个带有4个下拉列表控件的表单,我用DB表填充数据

。我有一个类,它有一个构造一个

数据集的方法,将每个数据库表放入一个数据集表中。然后我返回

DS并将表绑定到相关控件。

我一直在读DataView阅读器比
$ b $更有效率b DS用于从数据库中获取数据。

因此,最好有4个方法,每个方法返回一个dataReader,或者

填充数据集并返回的方法那个?


任何意见都会受到赞赏。

Hi all,

I have a form with 4 dropdownlist controls which I populate with data
from DB tables. I have a class with a method which constructs a
dataset, putting each DB table into a dataset table. I then return the
DS and bind the tables to the relevant controls.
I''ve been reading that DataReaders are much more efficient than
DS''s for getting data from the database.
So would it better to have 4 methods, each returning a dataReader, or
one method populating a dataset and returning that?

Any opinions would be appreciated.

推荐答案

我认为大部分意见您将找到的示例将使用数据集。

datareaders需要一些小心,因为您必须明确关闭它们

以防止保持开放连接(或者至少使用它这是

方式)。在任何情况下,我认为与可能影响页面性能的其他因素相比,任何效率提升都可能是微不足道的。


Jim


^ MisterJingo ^写道:
I think most of the examples you''ll find will use datasets.
datareaders require some care in that you have to explicitly close them
to prevent leaving an open connection (or at least it used to be this
way). In any event I think any efficiency gain will probably be
trivial compared to other factors that might affect the performance of
your page.

Jim

^MisterJingo^ wrote:
大家好,

我有一个带有4个下拉列表控件的表单,我从数据库表填充数据。我有一个类,它有一个构造
数据集的方法,将每个数据库表放入数据集表中。然后我返回
DS并将表绑定到相关控件。
我一直在读,DataReader比从数据库中获取数据的效率要高得多。
那么最好有4个方法,每个方法返回一个dataReader,或者一个方法填充数据集并返回它?

任何意见都将不胜感激。
Hi all,

I have a form with 4 dropdownlist controls which I populate with data
from DB tables. I have a class with a method which constructs a
dataset, putting each DB table into a dataset table. I then return the
DS and bind the tables to the relevant controls.
I''ve been reading that DataReaders are much more efficient than
DS''s for getting data from the database.
So would it better to have 4 methods, each returning a dataReader, or
one method populating a dataset and returning that?

Any opinions would be appreciated.






中间地带方法是使用IDataReader来填充一些

类的集合。

在1.1中,它是一个对象(如Employee)和一个集合(EmployeeCollection

:CollectionBase)


在2.0中,它是一个对象(如Employee)和一个新的List< Employee> (通用)


我有一个完整的可下载示例:

http://spaces.msn.com/sholliday/ 5/24/2006条目



< ; JH ***** @ yahoo.com>在消息中写道

news:11 ********************** @ c74g2000cwc.googlegr oups.com ...
The "middle ground" approach would be to use a IDataReader to populate some
kind of collection.
In 1.1, its an object (like Employee), and a collection (EmployeeCollection
: CollectionBase)

In 2.0, its an object (like Employee) and a new List<Employee> ( a generic )

I have a complete downloadable example at:

http://spaces.msn.com/sholliday/ 5/24/2006 entry


<jh*****@yahoo.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
我认为你会发现的大部分例子都会使用数据集。
数据引擎需要一些注意,因为你必须明确地关闭它们
以防止保持开放连接(或至少它曾经是这个
方式)。无论如何,我认为与可能影响页面性能的其他因素相比,任何效率提升都可能是微不足道的。

Jim

^ MisterJingo ^写道:
I think most of the examples you''ll find will use datasets.
datareaders require some care in that you have to explicitly close them
to prevent leaving an open connection (or at least it used to be this
way). In any event I think any efficiency gain will probably be
trivial compared to other factors that might affect the performance of
your page.

Jim

^MisterJingo^ wrote:
大家好,

我有一个带有4个下拉列表控件的表单,我用数据库表填充数据。我有一个类,它有一个构造
数据集的方法,将每个数据库表放入数据集表中。然后我返回
DS并将表绑定到相关控件。
我一直在读,DataReader比从数据库中获取数据的效率要高得多。
那么最好有4个方法,每个方法返回一个dataReader,或者一个方法填充数据集并返回它?

任何意见都将不胜感激。
Hi all,

I have a form with 4 dropdownlist controls which I populate with data
from DB tables. I have a class with a method which constructs a
dataset, putting each DB table into a dataset table. I then return the
DS and bind the tables to the relevant controls.
I''ve been reading that DataReaders are much more efficient than
DS''s for getting data from the database.
So would it better to have 4 methods, each returning a dataReader, or
one method populating a dataset and returning that?

Any opinions would be appreciated.



这完全取决于你想要对数据做什么。根据您的描述,

您不会更改数据库中用于填充DropDownList控件的任何数据。如果是这种情况,你可以通过使用DataReader初始化它们来获得一些性能

而不是DataSet。它可以像运行查询或存储

对数据库的过程一样简单,并使用DataReader填充

数组或集合,然后可以使用它来绑定到DropDownList

控制。


-

HTH,


凯文Spencer

Microsoft MVP

专业开发Numbskull


Nyuck nyuck nyuck

" ^ MisterJingo ^ " < MI ********* @ gmail.com>在消息中写道

news:11 ********************** @ j55g2000cwa.googlegr oups.com ...
It all depends on what you want to do with the data. From your description,
you are not going to change any of the data in the database that is being
used to populate the DropDownList Controls. If that is the case, you would
certainly gain some performance by initializing them using a DataReader
instead of a DataSet. It could be as simple as running a query or Stored
Procedure against your database, and using the DataReader to populate an
Array or Collection, which you can then use to bind to the DropDownList
Control.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Development Numbskull

Nyuck nyuck nyuck
"^MisterJingo^" <mi*********@gmail.com> wrote in message
news:11**********************@j55g2000cwa.googlegr oups.com...
大家好,

我有一个带有4个下拉列表控件的表单,我用DB表中的数据填充。我有一个类,它有一个构造
数据集的方法,将每个数据库表放入数据集表中。然后我返回
DS并将表绑定到相关控件。
我一直在读,DataReader比从数据库中获取数据的效率要高得多。
那么最好有4个方法,每个方法返回一个dataReader,或者一个方法填充数据集并返回它?

任何意见都将不胜感激。
Hi all,

I have a form with 4 dropdownlist controls which I populate with data
from DB tables. I have a class with a method which constructs a
dataset, putting each DB table into a dataset table. I then return the
DS and bind the tables to the relevant controls.
I''ve been reading that DataReaders are much more efficient than
DS''s for getting data from the database.
So would it better to have 4 methods, each returning a dataReader, or
one method populating a dataset and returning that?

Any opinions would be appreciated.



这篇关于数据集或datareader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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