我在这里遇到了一些问题。我的编码没有错误,但是当我调试编码时,它没有显示数据库中的任何数据。
这是我的pagebehind
string nm = name.SelectedValue.ToString();
string id = ID.SelectedValue.ToString();
if (name != "ALL" && ID != "ALL")
{
str = "SELECT DISTINCT Name, StaffID FROM employeeID WHERE Name ='"+nm+"' AND StaffID ='"+id+"'"+
"ORDER BY Name, StaffID";
ds = con.ExecuteDataSet(str);
grdA.DataSource = dset;
grdA.DataBind();
}
protected void grdA_RowDataBound(object sender, GridViewRowEventArgs e)
{
string nm = name.SelectedValue.ToString();
string id = ID.SelectedValue.ToString();
DataRowView tableData = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label nme = e.Row.FindControl("lblNM") as Label;
Label idd = e.Row.FindControl("lblID") as Label;
GridView grdB = e.Row.FindControl("grdB") as GridView;
str = "SELECT ClassA, ClassB, TotalStudent FROM tuition WHERE Name = '" + nme.Text + "' AND StaffID='" + idd.Text + "' ORDER BY ClassA";
ds = dbCon.ExecuteDataSet(str);
grdB.DataSource = dset;
grdB.DataBind();
if (grdB.Rows.Count != 0)
{
str = "SELECT NVL(SUM(ClassA),0)ClassA,NVL(SUM(ClassB),0)ClassB,NVL(SUM(TotalStudent),0)TotalStudent FROM tuition WHERE Name = '" + nme.Text + "' AND StaffID='" + idd.Text + "' ORDER BY ClassA";
OracleDataReader odr = dbCon.ExecuteReader(str);
while (dr.Read())
{
Label lblnewCA = grdSatus.FooterRow.FindControl("lblnewCA") as Label;
lblnewCA.Text = dr.GetInt32(0).ToString();
Label lblnewCB = grdSatus.FooterRow.FindControl("lblnewCB") as Label;
lblnewCB.Text = dr.GetInt32(1).ToString();
}
odr.Dispose();
odr.Close();
}
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
}
dset.Dispose();
}
protected void grdSatus_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
string nm = name.SelectedValue.ToString();
string id = ID.SelectedValue.ToString();
DataRowView tableData = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label nme = e.Row.FindControl("lblNM") as Label;
Label idd = e.Row.FindControl("lblID") as Label;
GridView grdB = e.Row.FindControl("grdB") as GridView;
str = "SELECT ClassA, ClassB, TotalStudent FROM tuition WHERE Name = '" + nme.Text + "' AND StaffID='" + idd.Text + "' ORDER BY ClassA";
ds = dbCon.ExecuteDataSet(str);
grdB.DataSource = dset;
grdB.DataBind();
if (grdB.Rows.Count != 0)
{
str = "SELECT NVL(SUM(ClassA),0)ClassA,NVL(SUM(ClassB),0)ClassB,NVL(SUM(TotalStudent),0)TotalStudent FROM tuition WHERE Name = '" + nme.Text + "' AND StaffID='" + idd.Text + "' ORDER BY ClassA";
OracleDataReader odr = dbCon.ExecuteReader(str);
while (dr.Read())
{
Label lblnewCA = grdSatus.FooterRow.FindControl("lblnewCA") as Label;
lblnewCA.Text = dr.GetInt32(0).ToString();
Label lblnewCB = grdSatus.FooterRow.FindControl("lblnewCB") as Label;
lblnewCB.Text = dr.GetInt32(1).ToString();
}
odr.Dispose();
odr.Close();
}
}
dset.Dispose();
}
我还不能发布任何图片,所以我无法向您展示结果。
答案 0 :(得分:0)
检查WHERE子句。在调试器中停止代码,监视str变量并将内容复制到sql窗口。
如果WHERE子句不正确,你就会得到蹲下(没有)。