Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在ASP.Net中调用存储过程两次时出现超时异常_C#_Asp.net_Sql Server_Sql Server 2008 R2 - Fatal编程技术网

C# 在ASP.Net中调用存储过程两次时出现超时异常

C# 在ASP.Net中调用存储过程两次时出现超时异常,c#,asp.net,sql-server,sql-server-2008-r2,C#,Asp.net,Sql Server,Sql Server 2008 R2,我有一个在gridview中单击项时调用的函数。 该函数调用一个存储的procode void fp_GetMRVByItem(int ItemID) { DTMRVdetails = null; MIVP.ItemID = ItemID; MIVP.SubCategoryID = Convert.ToInt32(hfSubCategory.Value); //SubCategoryID; MIVP.MIVTypeID =

我有一个在gridview中单击项时调用的函数。 该函数调用一个存储的procode

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);
        }
    }

我不明白这个问题的原因是什么。有人吗?

您是否尝试过用SQL手动运行存储过程以查看执行过程需要多长时间?这可能是因为您显示的代码没有问题,而只是因为该过程所花费的时间超出了超时允许的时间

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


如果最终是存储过程造成的,那么可能需要重新考虑。希望这只是一个简单的编码问题,您不会有更大的服务器问题

当我删除行MIVP.CustomerID=-1时;(左至使用其上一个值)不会发生超时。是否确实没有循环?你有没有通过密码?可能正在递归调用gridview加载。抛出的确切异常是什么?