0

我在 DataTable 中存储了一个 ADO 记录集。我已经迭代到它的结尾。在相同的代码中,我想重申它,但它给了我一个错误 -

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IndexOutOfRangeException: There is no row at position -1.
   at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
   at System.Data.RBTree`1.get_Item(Int32 index)
   at System.Data.DataRowCollection.get_Item(Int32 index)

我看了这里 - http://www.techrepublic.com/blog/10-things/10-plus-mistakes-to-avoid-when-using-vba-recordset-objects/ 但它并没有给我一个确切的方法将“行指针”移回第一行。

我该怎么做呢 ?

4

1 回答 1

1

使用 Recordset.MoveFirst() 方法。但是,这仅在打开记录集以支持向后光标移动时才有效。

这是包含更多信息的链接: 这里

于 2013-11-05T17:44:39.003 回答