我想在选定数据行上进行循环,而无需一次又一次地选择它们。所以我想把行设置回起始位置。代码应如下所示:
Table table;
select * from table where …;
while(table)
{
info(table.stringColumn);
next table;
}
somehow reset table position
//start from first selected row
while(table)
{
info(table.stringColumn);
next table;
}
我该怎么做?
答案 0 :(得分:3)
我会使用QueryRun
及其方法reset
。
但是,如果您只是想在已经检索到数据后再次从数据库中获取数据,则可以将所有检索到的记录存储在RecordLinkList
中,在线提供更多信息:http://msdn.microsoft.com/en-us/library/recordlinklist.aspx
如果您需要QueryRun
或RecordLinkList
的代码示例,请告知我们,我会将其添加到答案中。
P.S。如果您只对示例中的stringColumn感兴趣,只需将其值存储在容器或List中,然后在需要时将其存储。