Garbage disposal error

380
1
03-20-2022 11:52 PM
tzz_12
by
New Contributor III

Has anyone encountered an error that states the row declared has already been disposed and cannot be manipulated? How do I resolve this error? Thanks for your help!

Here is my code below: 

...

QueryFilter qf = new QueryFilter
{
WhereClause = CokeysWhereClause,

};

using (var rowCursor = HzTable.Search(qf))
{
while (rowCursor.MoveNext())
{
foreach (var compPct in compPcts)
{
using (Row row = rowCursor.Current)
{

var topHz = Convert.ToInt32(row["hzdept_r"]);         // disposed error occurs in the second loop
var bottomHz = Convert.ToInt32(row["hzdepb_r"]);

...

Thanks!

0 Kudos
1 Reply
GKmieliauskas
Esri Regular Contributor

Hi,

I think you must change two cycles by places:

using (Row row = rowCursor.Current)
{
    var topHz = Convert.ToInt32(row["hzdept_r"]);
    var bottomHz = Convert.ToInt32(row["hzdepb_r"]);
    foreach (var compPct in compPcts)
    {

rowCursor.Current  can be read once.

0 Kudos