Last post Oct 08, 2018 01:52 PM by mudassarkhan
Oct 08, 2018 11:21 AM|JagjitSingh|LINK
I have below code . If there is no record , what should be the value in dt
string strQuery = "Select * from Period where IsClosed = 'N'";
SqlDataAdapter sdaPeriod = new SqlDataAdapter(strQuery, con);
DataTable dt = new DataTable();
Oct 08, 2018 11:44 AM|mudassarkhan|LINK
It will be empty or null you can check as follows
if (dt != null && dt.Rows.Count > 0)
Oct 08, 2018 11:47 AM|JagjitSingh|LINK
If there is no record satisfying condition will it return 0 or null
Oct 08, 2018 12:50 PM|Mikesdotnetting|LINK
The DataTable will never be null because you used the new keyword to create an instance of it. It will just have no rows of data in it.
Oct 08, 2018 01:52 PM|mudassarkhan|LINK
The check which I gave will work for both conditions.
First will check NULL then Count.