473,382 Members | 1,180 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,382 software developers and data experts.

Checking for Empty Dataset -- Simple Question

Ron
Can anyone tell me how to check and see if a dataset is empty?

I am writing a search function that returns a dataset and binds it to a
datagrid. If no data is found, I would like to make the grid invisible and
have a label appear stating that no data was found.

Any suggestions?

Thanks,

Ron Rodenberg
Nov 17 '05 #1
2 18478
If MyDataSet.Tables.Count = 0 Then 'it's empty

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net

"Ron" <ro*@razorvision.net> wrote in message
news:be********@library1.airnews.net...
Can anyone tell me how to check and see if a dataset is empty?

I am writing a search function that returns a dataset and binds it to a
datagrid. If no data is found, I would like to make the grid invisible and
have a label appear stating that no data was found.

Any suggestions?

Thanks,

Ron Rodenberg

Nov 17 '05 #2
Ron
Thanks a lot Gaston, I appreciate your help.
"GastonQ" <ga************@yahoo.com.ar> wrote in message
news:04****************************@phx.gbl...
Hi Ron, to check an empty DataSet you must verify the Rows
of the DataTable object that contains the database query
result.

For example:
DataSet ds = new DataSet( "MyTable" );
...
if( ds.Tables[ "MyTable" ].Rows.Count == 0 )
// No records
else
// Do something...

Regards
Gaston Quirque
Microsoft MVP
-----Original Message-----
Can anyone tell me how to check and see if a dataset is

empty?

I am writing a search function that returns a dataset and

binds it to a
datagrid. If no data is found, I would like to make the

grid invisible and
have a label appear stating that no data was found.

Any suggestions?

Thanks,

Ron Rodenberg
.

Nov 17 '05 #3

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

Similar topics

2
by: Philip D Heady | last post by:
Hi, I'm validating a simple form for input via post ($PHP_SELF). Near the end I check for username and password. I'm using simple if, elseif, else statements. I require them to enter password...
1
by: arvee | last post by:
Hi - I'm updating an Oracle table with an empty string and getting the error: An unhandled exception of type 'System.Exception' occurred in system.data.dll Additional information: Parameter...
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
6
by: Mike P | last post by:
I have written a simple web service that basically takes a value input by a user and returns a dataset with all related data found in a database. In my client app use this code to get the data...
7
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. ...
22
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty...
10
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
2
by: Shum | last post by:
Hi! i have a question.. I'm filling a dataset from a table in which some rows are empty, i dont want those empty records to be filled in the dataset.. Does any one know how to restrict it to only...
3
by: Nader | last post by:
Hello, I read some files name from a directory and then I put these name in a list. I will check whether it is empty or not, and I would do it with an exception. With if statement it is very...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.