在ASP.Net中调用两次存储过程时发生TimeOut异常

本文关键字:存储过程 两次 异常 TimeOut Net ASP 调用 | 更新日期: 2023-09-27 17:53:16

我有一个函数,当我在gridview中单击项目时调用。该函数调用存储过程。函数是,

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);
        }
    }
我不明白这个问题的原因是什么。有人吗?

在ASP.Net中调用两次存储过程时发生TimeOut异常

您是否尝试过在SQL中手动运行存储过程以查看执行需要多长时间?您所展示的代码段可能没有问题,而只是过程所花费的时间超过了您的超时所允许的时间。

考虑增加允许的超时时间。这可以在你的网页上完成。配置文件,也在IIS(如果您使用ISS托管您的网站)。我想提供更多的细节,但你没有指定你得到什么样的超时异常…是页面请求超时还是数据库超时?

最终,如果你的存储过程应该受到责备,那么它可能需要重新考虑。希望这只是一个简单的编码问题,你没有更大的服务器问题!