System.IndexOutOfRangeException: Cannot find table 0

The trouble might be here:

if (ds.Tables[0].Rows.Count > 0)

First check if the table with the index of 0 exists, then try to access the properties…

if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 )

This should help. Or at least it’ll tell you that the returned dataset is empty (has no tables inside).

Leave a Comment