1

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 .

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160
Bala
  • 125
  • 1
  • 2
  • 12
  • server is not responding that means, you are not able to connect to the database, find the connection string in web.config and try to connect using SQL Management Studio, to make sure that you are able to connect to the database – Ayman Barhoum Nov 03 '15 at 12:30
  • Is the connection shared? Don't reuse it or make it even shared. Instead create it in this method with the `Using`-statement. – Tim Schmelter Nov 03 '15 at 12:30
  • 1
    Possible duplicate of [Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated](http://stackoverflow.com/questions/8602395/timeout-expired-the-timeout-period-elapsed-prior-to-completion-of-the-operation) – Ehsan Sajjad Dec 23 '16 at 11:34

3 Answers3

0

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.

MusicLovingIndianGirl
  • 5,909
  • 9
  • 34
  • 65
0

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.

Abbas
  • 1
  • 2
0

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