通过一个DataReader迭代两次两次、迭代、DataReader

由网友(慌了流年碎了梦)分享简介:我需要通过一个DataReader迭代两次。有没有办法做到这一点,而无需使用数据集,并没有运行查询两次?我使用C#,顺便说一句。谢谢I need to iterate twice through a DataReader. Is there a way to do this without using DataS...

我需要通过一个DataReader迭代两次。有没有办法做到这一点,而无需使用数据集,并没有运行查询两次?我使用C#,顺便说一句。 谢谢

I need to iterate twice through a DataReader. Is there a way to do this without using DataSets and without running the query twice? I'm using C#, by the way. Thanks

推荐答案

简短的回答是否定的,你通过枚举的结果集运行,然后就大功告成了。什么也许应该做的是结果转储到某种简单的原始结果,你可以遍历,只要你想(避免DataSet的开销)为多。

The short answer is no, you run through the enumeration for the result sets and then you're done. What should probably be done is to dump the results to some kind of simplified raw results that you can iterate over as much as you want (avoiding the overhead of the DataSet).

如果你把偷看的 MSDN ,它指出,SqlDataReader的是只向前,这将再次表明,这是不可能的。

If you take a peek at MSDN, it notes that the SqlDataReader is "forward only" which would suggest again that this isn't possible.

阅读全文

相关推荐

最新文章