我有一个函数,当我点击gridview中的项目时调用。 该函数调用存储的procodure。函数是,
void fp_GetMRVByItem(int ItemID)
{
DTMRVdetails = null;
MIVP.ItemID = ItemID;
MIVP.SubCategoryID = Convert.ToInt32(hfSubCategory.Value); //SubCategoryID;
MIVP.MIVTypeID = Convert.ToInt16(hfMIVTypeID.Value);
if (hfMIVTypeID.Value == "2")
{
if (gvMIVMRV.Rows.Count > 0 && DTMIVMRV.Rows.Count > 0)
{
MIVP.CustomerID = Convert.ToInt32(DTMIVMRV.Rows[0]["CustomerID"].ToString());
MIVP.JobOrderID = Convert.ToInt32(DTMIVMRV.Rows[0]["JobOrderID"].ToString());
}
else
{
MIVP.CustomerID = Convert.ToInt32(hfCustomerID.Value);
MIVP.JobOrderID = Convert.ToInt32(hfJobOrderID.Value);
}
DTMRVdetails = MIVBLL.MRVGridLoad(MIVP);//This call works perfectly.But when i moved flow moved into
// the following if I reset values to CustomerID,JobOrderID and again call the SP.Here I get
// the exception
//Timeout expired.The timeout period elapsed prior to completion of the operation or the server is not responding.
if (DTMRVdetails.Rows.Count == 0 && gvMIVMRV.Rows.Count == 0)
{
MIVP.CustomerID = -1;
MIVP.JobOrderID = -1;
DTMRVdetails = MIVBLL.MRVGridLoad(MIVP);//Timeout expired.The timeout period elapsed prior to completion of the operation or the server is not responding.
}
fp_GridViewSource(gvMRVdetails, DTMRVdetails);
}
else
{
MIVP.CustomerID = Convert.ToInt32(hfCustomerID.Value);
MIVP.JobOrderID = Convert.ToInt32(hfJobOrderID.Value);
//if (gvMRVdetails.Rows.Count > 0)
// DTMRVdetails.Merge(MIVBLL.MRVGridLoad(MIVP), false, MissingSc6hemaAction.Ignore);
//else
DTMRVdetails = MIVBLL.MRVGridLoad(MIVP);
//MRVMIVAccordion.SelectedIndex = 0;
fp_GridViewSource(gvMRVdetails, DTMRVdetails);
}
}
我无法理解这个问题的原因是什么。是否有任何身体?
答案 0 :(得分:1)
您是否尝试在SQL中手动运行存储过程以查看执行所需的时间?可能是您所显示的代码片段没有问题,而只是说该过程花费的时间比您的超时时间长。
考虑增加允许的超时时间。这可以在您的web.config文件中完成,也可以在IIS上完成(如果您使用ISS来托管您的网站)。我会提供更多有关此内容的详细信息,但您还没有指定您获得的超时异常类型...是页面请求超时还是数据库超时?
最终,如果您的存储过程受到责备,那么也许需要重新考虑。希望这只是一个简单的编码问题而且你没有更大的服务器问题!