读书人

关于种和方法

发布时间: 2012-10-29 10:03:53 作者: rapoo

关于类和方法
在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){
...
}

读书人网 >asp.net

热点推荐