多个表查询后放到一个Dataset中怎么判断查询结果集的条数?代码如下:
方法:
public DataSet GetNFieldDataSet(string TableName,string outFieldsql,string strWhere)
{
//请根据您的配置需要,更改DataAccessQuickStart的名称
Database db = DatabaseFactory.CreateDatabase( "DataAccessQuickStart ");
string strconn = db.GetConnection().ConnectionString;
OracleConnection con = new OracleConnection(strconn);
string sqlCommand = " Select "+outFieldsql+ " From "+TableName;
if(strWhere != " ")
{
sqlCommand += " where "+strWhere;
}
DataSet ds=new DataSet();
OracleDataAdapter da=new OracleDataAdapter(sqlCommand,con);
da.Fill(ds, "table ");
return ds;
}
查询语句:
string TableName8= "(select distinct(a.city_salesstation_d_id),a.puresaledamount,a.calendartime,a.citycode,a.gameno,b.isregular from tc_city_salesstation_d a,tc_games b where b.isregular=1 ) ";
string outFieldsql8= "sum(PureSaledAmount) as PureSaledAmount,citycode ";
string strWhere8= "to_number(to_char(CalendarTime, 'yyyy '))= "+YearNo+ " and to_number(to_char(calendartime, 'mm '))= "+MonthNO+ " and citycode= ' "+ds.Tables[0].Rows[i][ "CITYCODE "].ToString()+ " ' group by citycode ";
DataSet ds8=cdb1.GetNFieldDataSet(TableName8,outFieldsql8,strWhere8);
double text8=0;
int u=ds8.Tables[ "0 "].Rows.Count;
if(ds8.Tables[0].Rows.Count> 0)
{
text8=Convert.ToDouble(ds8.Tables[0].Rows[0][ "PureSaledAmount "].ToString());
myDataGrid.Items[i].Cells[8].Text=ds8.Tables[0].Rows[0][ "PureSaledAmount "].ToString();
}
else
{
myDataGrid.Items[i].Cells[8].Text= "0 ";
}
我不知道为什么在oracle中查询的时候我能得到结果集但是,在此处我取dataset中记录集的条数确是0,大家帮我看看
------解决方案--------------------int u=ds8.Tables[ "0 "].Rows.Count;
改成
int u=ds8.Tables[ "table "].Rows.Count;