开发者

How to retrieve only one field from that Dataset?

开发者 https://www.devze.com 2023-01-28 11:10 出处:网络
I have Dataset which filled with the Data of All User Or Particular one User. I have to retrieve only one field from that Dataset, What is the Optimal way of doing that.

I have Dataset which filled with the Data of All User Or Particular one User.

I have to retrieve only one field from that Dataset, What is the Optimal way of doing that.

I am currently using foreach to retrieve the reco开发者_开发问答rd.

If possible,Provide some examples of doing that in smart way.

Thank U


The answer really depends on a lot of variables.

The first question I would ask is this: Is your system noticeably slow when retrieving this data? If no, then don't bother changing anything.

If it is slow, then you can do a number of different things:

  • If you are retrieving this data frequently, consider cacheing it and accessing the cached copy.
  • If cacheing is not possible, don't use DataSets at all. Consider the use of ExecuteScalar for the case of returning the single field for a single user, or ExecuteReader for getting the field for the case of the data set containing all users.
0

精彩评论

暂无评论...
验证码 换一张
取 消