数据集只返回一个值 [英] Dataset returning only one value

查看:76
本文介绍了数据集只返回一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是





my code is


try
   {
   string html = string.Empty;
   string search_query = @"select * from table";

                           SELECT * from table2;

   SqlCommand sql_cmd = new SqlCommand(search_query,con);
   //SqlDataReader rdr_university = Ou4.GetReader(search_query);
   SqlDataAdapter adp = new SqlDataAdapter(sql_cmd);
   DataSet ds = new DataSet();
   adp.Fill(ds);
}





它只返回单个值,但根据条件它应返回两行。请帮帮我



it return only single value but according to condition it should return two rows. please help me

推荐答案

它给出了DataSet中的两个记录集,



你的条件应该是.. :)



it gives two record set in DataSet,

your condition should be.. :)

if (ds.Tables.Count > 'What ever you want in integer')





EG





E.G.

DataSet ds = new DataSet();

       int DataRowCount = 0;
       DataRowCount = ds.Tables.Count; //it returns number of tables in dataset.
       DataRowCount = ds.Tables[0].Rows.Count; //it returns number of rows in first resordset.
       DataRowCount = ds.Tables[1].Rows.Count; //it returns number of rows in Second resordset.


为什么?

这是两个单独的查询,每个查询都可能返回一个结果。

因此,我希望每个查询返回一个单独的DataTable,每个DataTable包含一行。
Why?
It's two separate queries, each of which will presumably return one result.
As a result, I would expect each query to return a separate DataTable, each containing one row.


这篇关于数据集只返回一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆