Determine if the dataset is empty and whether there are tables in the dataset and whether there is data in the table

Source: Internet
Author: User

It's common to know if a dataset is empty, but I'm starting to get a little vague on the concept of DS empty, and I looked at it online, and the results are as follows: The dataset is empty and there are no tables in the dataset.

The dataset is empty, or a reference to a dataset type is null, meaning that the reference variable does not point to any new memory block.

Ds:dataset

if (ds = = null)//ds is empty

if (ds. Tables.count = = 0) No table in//ds

if (ds. Tables.count = = 1 && ds. Tables[0]. Rows.Count = = 0) The table in//ds has no data

We also need to determine if a table exists in the DS after we have determined if the DS is empty, and then we need to determine whether there is data in the table when using the table. The following is an example that determines whether a table exists in a dataset.

DataSet _ds = new DataSet ();

DataTable _dt = new DataTable ("TableName");

_ds. Table.add (_DT);

if (_ds! = null)

{

if (_ds. Tables.contains (_dt. TableName)

{

Presence Table

}

}

Determine if the dataset is empty and whether there are tables in the dataset and whether there is data in the table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.