473,387 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to check if table is empty

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
Nov 16 '05 #1
2 21996
cm=(CurrencyManager)this.BindingContext[customersTable,""];
if(cm.Count>0) // or if(cm.Position>=0)
IsEmpty=false;
else
IsEmpty=true;
"hodari" <ho****@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
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

Nov 16 '05 #2
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
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sigurd Urdahl | last post by:
I need to do CHECK TABLE on a lot of tables (actually on all tables in several databases), and hoped to do something like mysql> CHECK TABLE reports.* which ddn't work. The only thing that...
3
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form...
2
by: Paul Telco | last post by:
Hello, I'm a new user designing a simple database to retrieve pre-prepared docunents for printing. I have five tables, a form to design the documents, a form to customise and retrieve the...
30
by: S. van Beek | last post by:
Dear reader A record set can be empty because the condition in the query delivers no records. Is there a VBA code to check the status of a record set, record set empty
1
by: Oleg Ogurok | last post by:
Hi all, I want to use RegularExpressionValidator to enforce non-empty integer format in a TextBox. However, the validator doesn't give the error when the textbox is empty. For example, if...
4
by: whisher | last post by:
Hi. I'm taking my first steps on regex I set up this simple function to check if a form field is empty or with only space. var onlySpaceRegexp = /^\s*$/; function isEmpty(val) { if...
7
by: lphang | last post by:
I am reading a simple text file that will contains three set of string values as follow: "1234567", "ABC123456", "" I have my codes as follow trying to check for an empty string, with the input...
3
by: akshalika | last post by:
I want regular expression which check for empty. pls help me.
18
JustRun
by: JustRun | last post by:
Hi, I just want to know what is the number that will return if the table is empty "has no record" Is it ' 0 ' ?
10
by: klharding | last post by:
I am reading the contents of a text file into variables. All works well if the text file does not exist, or it does exist and contains 4 rows of data. But I need to account for rows being empty or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.