http://blog.sina.com.cn/jiangshuqin2010
1,if (ds = = null) This is to determine if the data set in memory is empty, the dataset is empty, the rows and columns do not exist!!
2,if (ds. Tables[0]. Count = = 0) This should be a dataset in memory, but there is no table in the DataSet!!
3,if (ds. Tables[0]. Count = = 1 && ds. Tables[0]. Rows.Count = = 0) indicates that there are table tables, but there is no data in the table!
1 if(yourdataset.tables[0]. Rows.Count >0 )2 {3 //What you have to do when you have a record4 }5 Else6 {7 //Return empty Set8 }9 if(dataset1.tables[0]. Rows.Count = =0)Ten { OneResponse.Write ("<script language=javascript>alert (' No record! '); </script>"); A}
Recommendation (Yourdataset.tables[0]. Rows.Count > 0) or (ds.tables==null) should first determine if the dataset is empty (when a query is faulted), and then determine whether the number of rows in the table is 0 (the query is not faulted and the number of rows is 0), otherwise error-prone,
For example: First Judge Mydataset.tables[0]. Rows.count==0, if the query error, at this time mydataset is null, there is no table, so will error.
So it should be judged
1 if (myDataSet = null | | Mydataset.tables[0 ]. Rows.Count = = 0 ) 2 { 3 // 4 5 else 6 { // not empty when handling 8 }
"| |" and the "&&" Operation Mr. Foo judge the first condition, not satisfied and then judge the next condition, but if the above order exchange in myDataSet is NULL, it will be wrong, that is, first judge the big condition, then judge the small condition
Go: Determine if the dataset is empty