ADO.NET问:什么时候使用的DataReader,DataAdapter的 [英] ADO.NET Question: When to use DataReader, DataAdapter

查看:275
本文介绍了ADO.NET问:什么时候使用的DataReader,DataAdapter的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道,我有什么东西从数据库中获取数据和最新这两个DataReader的之间的差异需要打开连接和datadapter不...在我们的项目中,分别使用的DataReader和DataAdapter时要考虑在我们所有的DAL使用DataReader的,我们从来不使用的DataAdapter。所以,我想知道什么情况下会是更好用的DataAdapter + DataTable的组合比使用DataReader的。先谢谢了。

i just wondering, what things i have to consider when using DataReader and DataAdapter in fetching data from the database and whats the difference between this two other the datareader needs open connection and the datadapter does not... In our projects, were using DataReader in ALL our DAL, we never use dataadapter. So I wondering what scenario would it been better to use DataAdapter + Datatable combo than using DataReader. Thanks in advance.

推荐答案

DataReader的:这是最好的使用,当你只是想获取在readony模式数据,填充您的业务实体,并关闭读卡器。这实在是快。

DataReader : This is best used when you just want to fetch data in readony mode , populate your business entity and close the reader. This is really fast.

说假设,你有一个客户类,并要与所有客户的属性填充像(姓名,地址等)

Say suppose , you are having a customer class and you want to have fully initilized object with all your customer properties filled like( Name,Address etc..)

您将在这里使用的DataReader,只是填充实体和关闭的读者。

You will use DataReader here and just populate the entity and close reader.

您不能DataReader的做更新。

You cannot do update with datareader.

DataAdapter的:可以读取/更新与dataadapters的数据,但它是不太更快读取数据时则DataReader的

DataAdapter : You can Read/Update the data with dataadapters but it is less faster when reading the data then Datareader.

您可以更新与DataAdapter的数据,但是与读者你不会

You can update the data with DataAdapter but with reader you won't

这篇关于ADO.NET问:什么时候使用的DataReader,DataAdapter的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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