简体   繁体   中英

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

My Procedure is like this ,

sqlCmd = New SqlCommand("sp_JBM_ProductionReprt", myConnection)
                sqlCmd.CommandType = CommandType.StoredProcedure
                sqlCmd.Parameters.Add(New SqlParameter("@Type", Data.SqlDbType.VarChar)).Value = SessionHandler.sCustAcc
                sqlCmd.Parameters.Add(New SqlParameter("@FromDate", Data.SqlDbType.DateTime)).Value = strFromDate
                sqlCmd.Parameters.Add(New SqlParameter("@ToDate", Data.SqlDbType.DateTime)).Value = strToDate
                sqlCmd.Parameters.Add(New SqlParameter("@TblChapterInfo", Data.SqlDbType.VarChar)).Value = Init_Tables.gTblChapterInfo
                sqlCmd.Parameters.Add(New SqlParameter("@TblProdStatus", Data.SqlDbType.VarChar)).Value = Init_Tables.gTblProdStatus
                sqlCmd.Parameters.Add(New SqlParameter("@Condition", Data.SqlDbType.VarChar)).Value = strCondition
                sqlCmd.Parameters.Add(New SqlParameter("@EmpSelection", Data.SqlDbType.VarChar)).Value = strEmpSel
                sqlCmd.Parameters.Add(New SqlParameter("@SubTeamID", Data.SqlDbType.VarChar)).Value = " "

            myConnection.Open()
            sqlCmd.Connection = myConnection
            'sqlCmd.CommandTimeout = 10
            myReader = New SqlDataAdapter(sqlCmd)

            myReader.Fill(ds)

am waiting less than one minute and am getting this error

the timeout period elapsed prior to completion of the operation or the server is not responding.

I added in web config

<httpRuntime maxRequestLength="2097151" executionTimeout="10800" />

but i get same error .

and also i tried this

sqlCmd.CommandTimeout = 10

Please suggest me to find a solution .

Check if your connection remains open and is not disposed since this will cause the connection pool to exhaust. Your issue will be fixed if you dispose the connection properly.

Also check whether your DB statistics/query plan is correct. If not, clear it using

exec sp_updatestats

Also, setting commandTimeOut will help.

ExecutionTimeout in web.config : Specifies the maximum number of seconds that a HTTP request is allowed to execute

CommandTimeout : Specifies the maximum number of seconds that a SQL command is allowed to execute

Try setting the CommandTimeout to higher value. Default is 30 seconds .

Increase your CommandTimeout

        DataSet ds = new DataSet();
        SqlConnection myConnection= new SqlConnection(connectionString);
        myConnection.Open();
        SqlCommand sqlCmd= new SqlCommand("sql statement");
        sqlCmd.Connection = myConnection;
        sqlCmd.CommandTimeout = 90;
        myReader = New SqlDataAdapter(sqlCmd);
        myReader.Fill(ds)
        myConnection.Close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question SQL Server Exception:Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding ExecuteQueryin linq :Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding Linq Count() timing out -Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding Execute package in ssis causes Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. working on remote windows .net Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding C# entityframework core throwing Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding 'Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM