方法:
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,大家帮我看看
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,大家帮我看看
代码如下:
string TableName5="(select * from tc_city_salesstation_d where gameNo=03)";
string outFieldsql5="sum(PureSaledAmount) as PureSaledAmount,cityCode ";
string strWhere5=" 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 ds5=cdb1.GetNFieldDataSet(TableName5,outFieldsql5,strWhere5);
double text5=0;
if(ds5.Tables[0].Rows.Count>0)
{
text5=Convert.ToDouble(ds5.Tables[0].Rows[0]["PureSaledAmount"].ToString());
myDataGrid.Items[i].Cells[5].Text=ds5.Tables[0].Rows[0]["PureSaledAmount"].ToString();
}
else
{
myDataGrid.Items[i].Cells[5].Text="0";
}
改成
int u=ds8.Tables["table"].Rows.Count;