日期:2014-05-17  浏览次数:20577 次

关于类和方法
在helper()类里有一个Ycxt()查询的方法,在别的页面调用这个方法,怎么判断是否查询到数据
数据库是oracle
helper()类
C# code

public void Ycxt(string ex)
    {
        OracleConnection conn = new OracleConnection(ConnectionString);
        string sql = "select * from table_journal where xinxi='"+ ex.ToString().Trim() +"'";
        OracleDataAdapter da = new OracleDataAdapter(sql,conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
    }


其他页面调用
C# code

try
        {

        }
        catch (Exception ex)
        {
            helper log = new helper();
            log.Ycxt(ex.ToString());//这里怎样判断是否查询到了数据
        }



------解决方案--------------------
可以判断datatable的rows的数量
------解决方案--------------------
public DataSet Ycxt(string ex)
{
 ....
 return ds
}
...
DataSet ds=log.Ycxt(ex.ToString())
if(ds.Table[0].Rows.Count>0){
...
}