Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Timeout problem

Timeout problem

Scheduled Pinned Locked Moved Database
databasehelpquestioncsharpasp-net
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gratisaccount
    wrote on last edited by
    #1

    Hi All, I have wrote stored procedure which calculates points for result for around 1000 users. This procedure takes no parameters from asp.net code. asp.net code is used for just for calling this procedure. But when I run this procedure from the code it gives me the timout error. while running from the sql server itself it works fine. Kindly tell me how can I overcome this problem? Below is my code, which is giving me the error. try { Helper connHLP = new Helper(false); connHLP.Retrieve("prcUpdateUsePoints", null); }catch (Exception ex) { throw ex; } ---------------------------------------------------------------------------------------------------------------------- Code for connection & retrive: private SqlConnection conn; private SqlTransaction tran; public Helper(bool TransactionRequired) { try { string strConn = string.Empty; strConn = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString(); conn = new SqlConnection(strConn); conn.Open(); if (TransactionRequired == true) { tran = conn.BeginTransaction(); } else { tran = null; } } catch (Exception ex) { throw ex; } } public DataSet Retrieve(string ProcedureName, SqlParameter[] ParamCollection) { try { DataSet ds = new DataSet();SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; if (ParamCollection != null) SetParameters(cmd, ParamCollection); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = ProcedureName; SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(ds); return ds; } catch (Exception ex) { throw ex; } finally { conn.Close(); } } public void SetParameters(SqlCommand cmd, SqlParameter[] ParamCollection) { try { foreach (SqlParameter param in ParamCollection) cmd.Parameters.Add(param); } catch (Exception ex) { throw ex; } } ---------------------------------------------------------------------------------------------------------------------- Thnking you all in advance.

    K M G 3 Replies Last reply
    0
    • G gratisaccount

      Hi All, I have wrote stored procedure which calculates points for result for around 1000 users. This procedure takes no parameters from asp.net code. asp.net code is used for just for calling this procedure. But when I run this procedure from the code it gives me the timout error. while running from the sql server itself it works fine. Kindly tell me how can I overcome this problem? Below is my code, which is giving me the error. try { Helper connHLP = new Helper(false); connHLP.Retrieve("prcUpdateUsePoints", null); }catch (Exception ex) { throw ex; } ---------------------------------------------------------------------------------------------------------------------- Code for connection & retrive: private SqlConnection conn; private SqlTransaction tran; public Helper(bool TransactionRequired) { try { string strConn = string.Empty; strConn = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString(); conn = new SqlConnection(strConn); conn.Open(); if (TransactionRequired == true) { tran = conn.BeginTransaction(); } else { tran = null; } } catch (Exception ex) { throw ex; } } public DataSet Retrieve(string ProcedureName, SqlParameter[] ParamCollection) { try { DataSet ds = new DataSet();SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; if (ParamCollection != null) SetParameters(cmd, ParamCollection); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = ProcedureName; SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(ds); return ds; } catch (Exception ex) { throw ex; } finally { conn.Close(); } } public void SetParameters(SqlCommand cmd, SqlParameter[] ParamCollection) { try { foreach (SqlParameter param in ParamCollection) cmd.Parameters.Add(param); } catch (Exception ex) { throw ex; } } ---------------------------------------------------------------------------------------------------------------------- Thnking you all in advance.

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      The command object has a default timeout of 30 seconds. YOu will need to set this to some sort of timeout that is long enough for the stored procedure to run. If this is a really long running sp you may need to increase some of the web site timeouts as well. Hope that helps. Ben

      1 Reply Last reply
      0
      • G gratisaccount

        Hi All, I have wrote stored procedure which calculates points for result for around 1000 users. This procedure takes no parameters from asp.net code. asp.net code is used for just for calling this procedure. But when I run this procedure from the code it gives me the timout error. while running from the sql server itself it works fine. Kindly tell me how can I overcome this problem? Below is my code, which is giving me the error. try { Helper connHLP = new Helper(false); connHLP.Retrieve("prcUpdateUsePoints", null); }catch (Exception ex) { throw ex; } ---------------------------------------------------------------------------------------------------------------------- Code for connection & retrive: private SqlConnection conn; private SqlTransaction tran; public Helper(bool TransactionRequired) { try { string strConn = string.Empty; strConn = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString(); conn = new SqlConnection(strConn); conn.Open(); if (TransactionRequired == true) { tran = conn.BeginTransaction(); } else { tran = null; } } catch (Exception ex) { throw ex; } } public DataSet Retrieve(string ProcedureName, SqlParameter[] ParamCollection) { try { DataSet ds = new DataSet();SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; if (ParamCollection != null) SetParameters(cmd, ParamCollection); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = ProcedureName; SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(ds); return ds; } catch (Exception ex) { throw ex; } finally { conn.Close(); } } public void SetParameters(SqlCommand cmd, SqlParameter[] ParamCollection) { try { foreach (SqlParameter param in ParamCollection) cmd.Parameters.Add(param); } catch (Exception ex) { throw ex; } } ---------------------------------------------------------------------------------------------------------------------- Thnking you all in advance.

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        Query Analyzer/Management Studio does not time out. In contrast, ADO.NET does have a default command timeout of 30 seconds. To change this, change the SqlCommand's CommandTimeout property. You should consider investigating why this command is taking so long, however. Blocking an ASP.NET worker thread for any significant length of time seriously inhibits the scalability of your website.


        DoEvents: Generating unexpected recursion since 1991

        1 Reply Last reply
        0
        • G gratisaccount

          Hi All, I have wrote stored procedure which calculates points for result for around 1000 users. This procedure takes no parameters from asp.net code. asp.net code is used for just for calling this procedure. But when I run this procedure from the code it gives me the timout error. while running from the sql server itself it works fine. Kindly tell me how can I overcome this problem? Below is my code, which is giving me the error. try { Helper connHLP = new Helper(false); connHLP.Retrieve("prcUpdateUsePoints", null); }catch (Exception ex) { throw ex; } ---------------------------------------------------------------------------------------------------------------------- Code for connection & retrive: private SqlConnection conn; private SqlTransaction tran; public Helper(bool TransactionRequired) { try { string strConn = string.Empty; strConn = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString(); conn = new SqlConnection(strConn); conn.Open(); if (TransactionRequired == true) { tran = conn.BeginTransaction(); } else { tran = null; } } catch (Exception ex) { throw ex; } } public DataSet Retrieve(string ProcedureName, SqlParameter[] ParamCollection) { try { DataSet ds = new DataSet();SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; if (ParamCollection != null) SetParameters(cmd, ParamCollection); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = ProcedureName; SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(ds); return ds; } catch (Exception ex) { throw ex; } finally { conn.Close(); } } public void SetParameters(SqlCommand cmd, SqlParameter[] ParamCollection) { try { foreach (SqlParameter param in ParamCollection) cmd.Parameters.Add(param); } catch (Exception ex) { throw ex; } } ---------------------------------------------------------------------------------------------------------------------- Thnking you all in advance.

          G Offline
          G Offline
          gratisaccount
          wrote on last edited by
          #4

          Thanks for your reply. Your answers could have solved my problem. If I limit the no. of users. But that is the problem. No. of users will increase in coming time. So if there is any other efficient way to solve this problem. Plz tell me

          K 1 Reply Last reply
          0
          • G gratisaccount

            Thanks for your reply. Your answers could have solved my problem. If I limit the no. of users. But that is the problem. No. of users will increase in coming time. So if there is any other efficient way to solve this problem. Plz tell me

            K Offline
            K Offline
            kubben
            wrote on last edited by
            #5

            Neither one of us suggested you needed to limit the number of user being returned. Both of us suggested that if you increase the timeout property of your command object then they will all return. If you look at the time in your query tool that it take to execute and it is like 1 minute, then increase your command timeout to like 2 minutes and you should be fine. If the time in it takes to execute is like 5 minutes then fix your query because you are missing indexes or something if it is taking that long to execute. Ben

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups