How to check if table is empty

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am currenlty using the following code to check if the table is empty. I
wonder if there is a more elegant way of doing this:

private bool IsEmptyTable()
{
int RecordCount;
DataTable customersTable = CustomerDB.GetCustomers();
RecordCount = customersTable.Rows.Count;
if (RecordCount != 0)
isEmpty = false;
else
isEmpty = true;
return isEmpty;
}

Thanks
 
cm=(CurrencyManager)this.BindingContext[customersTable,""];
if(cm.Count>0) // or if(cm.Position>=0)
IsEmpty=false;
else
IsEmpty=true;
 
Hodari,

Although not the best in academical question do you mean with table is empty
Is not instanced
(MyDataTable ==null)

Has by instance no rows?
(MyDataTable.Rows.Count == 0);

I hope this helps somehow.

Cor
 
Back
Top