在我的项目中,我从数据库中检索一些详细信息,将其存储在 Dataset 中并在 IF 条件下检查它,我将断点放在 IF 条件行中并执行它以检查它是否正确运行,条件失败(即那里我在数据可视化器中看到的数据集中也没有行)但它正在移动到 IF 块并且引发索引异常它 可能是什么错误,
我的代码是,
string mac = GetMac();
DataSet dr = Namespace.SP.Storedprocedure(mac).GetDataSet();
DataSet ds = Namespace.SP.Storedprocedure(mac).GetDataSet();
try
{
if (dr.Tables[0].Rows.Count > 0 || dr.Tables[0].Rows.Count <= 3)
{
string date = dr.Tables[0].Rows[0]["Date"].ToString();
if (Convert.ToInt32(dr.Tables[0].Rows[0]["CID"]) != Convert.ToInt32(Session["CollegeID"]))
{
Messaging("This System is already Registered Under Different College.");
getdet.Enabled = false;
Register1.Enabled = false;
}
else if (dr.Tables[0].Rows[0]["Mac_id"].ToString() == mac)
{
Messaging("This System has been Already Registered for Delivery on " + date);
getdet.Enabled = false;
Register1.Enabled = false;
}
}
else
{
Messaging("The Allowed Maximum Number of Systems has been Registered... ");
}
if (getdet.Enabled == false && Register1.Enabled == false && ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["Mac_id"] != mac)
{
getdet.Enabled = true;
Register1.Enabled = true;
}
}
ggvqpdetail.Visible = true;
fillgridQP();
foreach (GridViewRow gr in ggvdetail.Rows)
{
Anthem.Label lb = (Anthem.Label)gr.FindControl("lbl1");
lb.Text = "Downloading";
break;
}
}
catch(Exception ex)
{
lbltxt.Text = ex.Message;
}