0

Possible Duplicate:
How to test if a DataSet is empty?

I'm executing these lines

string commToExc = @"SELECT * FROM Test WHERE id = 500;";
MySqlCommand cmdSQL = new MySqlCommand(commToExc, conMYSQL);
MySqlDataAdapter zipcode = new MySqlDataAdapter(cmdSQL);
DataSet setTest = new DataSet("Test");

I'm taking data by their rows id. everthing works fine, i get the results i want but i have question. For example in db id = [1-500]. But i request row with id = 501 and i get 0 results back. Whats is the way to know when I got 0 results? Thnx

4

3 回答 3

5
if (setTest.Tables[0].Rows.Count == 0)
于 2012-09-20T08:38:49.903 回答
1

我想在某些时候你会填写 DS 如下所示:

zipcode.Fill(setTest );

然后,您可以使用DT 上Count的集合属性简单地检查如何返回行Rows

于 2012-09-20T08:41:10.387 回答
0

必须填写 DataSet,否则 DataSet 为空

于 2012-09-20T08:47:48.837 回答