检查它是否在SqlDataReader的最后一条记录 [英] Check if it's the last record in sqldatareader
本文介绍了检查它是否在SqlDataReader的最后一条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法来检查,如果我在最后一个记录?
感谢
Is there a way to check if I'm on the last record ? thanks
推荐答案
使用此模式来识别和结果处理的最后一行:
Use this pattern to identify and process the last row in result:
if (reader.Read())
{
var loop = true;
while (loop)
{
//1. Here retrive values you need e.g. var myvar = reader.GetBoolean(0);
loop = reader.Read();
if (!loop)
{
//You are on the last record. Use values read in 1.
//Do some exceptions
}
else {
//You are not on the last record.
//Process values read in 1., e.g. myvar
}
}
}
这篇关于检查它是否在SqlDataReader的最后一条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文