有没有办法检查我是否在最后一条记录中? 谢谢
最佳答案
使用此模式识别和处理结果中的最后一行:
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
}
}
}
关于c# - 检查它是否是sqldatareader中的最后一条记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11703305/