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

How to tell if a DataSet is null in ASP.net C# ?

Hi,

How to we tell if a DataSet is null in a ASP.Net C# Windows Form?
Is it possible that a DataSet is not null but has no DataTable?
What will be the simplest code?
Thanks for help.

Jason
Nov 17 '05 #1
3 33451
You can always check your object for a null value.

DataSet ds;
....
if ( ds == null ) ...

Or if it is not null, you can check for tables in it:

if ( ds.Tables.Count == 0 ) ... // error
-Lenard

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:uz**************@TK2MSFTNGP09.phx.gbl...
Hi,

How to we tell if a DataSet is null in a ASP.Net C# Windows Form?
Is it possible that a DataSet is not null but has no DataTable?
What will be the simplest code?
Thanks for help.

Jason

Nov 17 '05 #2
Hi Jason,

It's possible that a DataSet is not null but without any DataTable in it.
For example, you instance a DataSet:

DataSet ds = new DataSet();

The ds is not null, but there is no DataTable in it. Even if there are
DataTables in a DataSet, maybe there is not any data in it. See following
code:

DataTable tbl = new DataTable();
ds.Tables.Add(tbl);

The DataTable, tbl, is an empty one.

HTH

Elton Wang

"Jason Huang" wrote:
Hi,

How to we tell if a DataSet is null in a ASP.Net C# Windows Form?
Is it possible that a DataSet is not null but has no DataTable?
What will be the simplest code?
Thanks for help.

Jason

Nov 17 '05 #3
"Lenard Gunda" <ar**************@vipmail.hu> ha scritto nel messaggio
news:Ou**************@TK2MSFTNGP14.phx.gbl...
You can always check your object for a null value.

DataSet ds;
...
if ( ds == null ) ...

Or if it is not null, you can check for tables in it:

if ( ds.Tables.Count == 0 ) ... // error


All in a row:

if (( ds != null ) && ( ds.Tables.Count > 0 ))
// ok
else
// error
Note that

if (( ds.Tables.Count > 0 ) && ( ds != null ))

won't work ;)

--
..Net Reporting tool: http://www.neodatatype.net
Nov 17 '05 #4

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

Similar topics

1
by: RS | last post by:
I have a dataset that i read schema from the XSD file in to. After, i populate it with some values from the flat file. Fileds lend in to the right columns in the table however when i tell Dataset...
35
by: MuZZy | last post by:
Hi All, I got a issue here and hope someone can help me: Let's consider this code: // =================== CODE START ================================= using System; using System.Data; ...
0
by: RS | last post by:
I have a dataset that i read schema from the XSD file in to. After, i populate it with some values from the flat file. Fileds lend in to the right columns in the table however when i tell Dataset...
6
by: Kiran | last post by:
Hi, I am using typed dataset for Employees Table and found a problem, can anyone tell me what's wrong Case 1: Employees Table: ID: int,Not Null,Idendity, Primary col Name:varchar(20),Not...
1
by: Joe Goeke | last post by:
If I pull a DataSet from a SQL Server 2005 DB and the value of a column in the DB is null. What is the value of the same column in the DataSet? Is the value in the DataSet NULL or ""? Thanks...
2
by: Stanav | last post by:
Hello all, I'm developing a web application using VB.Net 2003 and Framework 1.1. This application queries an AS/400 database. I'm using the IBM OleDb provider that came with IBM Client Access for...
1
by: lucky | last post by:
Hi guys! i've filled the DatSet object and was trying to get xml data from it. i used GetXml() method for that. it worked fine when all columns of the datatable has data. it generates perfectly...
3
by: iKiLL | last post by:
Hi all The Code is below but i will give you a brief over view first. I am using C#, SQL Mobile and the CF2.0 with Merge Replication. My Primary Keys are all "uniqueidentifier" types...
2
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously...
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.