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.
精彩评论