none
Table.Rows.Count raising an exception RRS feed

  • Question

  • Hi,

    I have function that loads data from a datatable

    public bool LoadFromDataTable(DataTable Table)
            {
                if (Table.Rows.Count > 0)
                {
                    return (Automation.SetObjectFieldsFromDataRow(this, Table.Rows[0]) > 0);
                }
                return false;
            }

    I get a "There is no row at position 0." error on the if statement.... Surely this can not be????

    Is there anything that I am doing wrong?

    Thanks


    Wednesday, January 23, 2008 1:38 PM

All replies

  •  

    Could you post the code in SetObjectFieldsFromDataRow method? I would also check to make sure that the DataTable is not null as shown below.

     

    Code Snippet

     

    public bool LoadFromDataTable(DataTable Table)
    {
         if (Table != null && Table.Rows.Count > 0)
         {
             return (Automation.SetObjectFieldsFromDataRow(this, Table.Rows[0]) > 0);
         }
         return false;
    }

     

     


     

    Wednesday, January 23, 2008 2:27 PM