asp.net select 语句求和后 结果装在Dataset里,如何判断ds是否为空
DataBaseDB=newDataBase();stringstr="select*fromsbxxcoursewheresfzID='"+Session["UserI...
DataBase DB = new DataBase();
string str = "select * from sbxxcourse where sfzID='" + Session["UserID"].ToString() + "' ";
DataSet myds1 = DB.GetDataSetSql(str);//调用DataBase类方法GetDataSetSql方法查询数据
string str1 = "select sum(xuefen) as xuefen1 from sbxxcourse where sfzID='" + Session["UserID"].ToString() + "' and chengji='合格'";
DataSet ds = DB.GetDataSetSql(str1);
if (myds1.Tables[0].Rows.Count > 0)
{
lblxm.Text = myds1.Tables[0].Rows[0]["xsname"].ToString();
lblxuehao.Text = myds1.Tables[0].Rows[0]["xuehao"].ToString();
if (ds != null )
{
lblxuefen.Text = ds.Tables[0].Rows[0]["xuefen1"].ToString();
}
else
{
lblxuefen.Text = "0";
}
}
else
{
Response.Write("<script>alert('您还没有选修课');</script></script> ");
} 展开
string str = "select * from sbxxcourse where sfzID='" + Session["UserID"].ToString() + "' ";
DataSet myds1 = DB.GetDataSetSql(str);//调用DataBase类方法GetDataSetSql方法查询数据
string str1 = "select sum(xuefen) as xuefen1 from sbxxcourse where sfzID='" + Session["UserID"].ToString() + "' and chengji='合格'";
DataSet ds = DB.GetDataSetSql(str1);
if (myds1.Tables[0].Rows.Count > 0)
{
lblxm.Text = myds1.Tables[0].Rows[0]["xsname"].ToString();
lblxuehao.Text = myds1.Tables[0].Rows[0]["xuehao"].ToString();
if (ds != null )
{
lblxuefen.Text = ds.Tables[0].Rows[0]["xuefen1"].ToString();
}
else
{
lblxuefen.Text = "0";
}
}
else
{
Response.Write("<script>alert('您还没有选修课');</script></script> ");
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询