Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 266841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:28:38+00:00 2026-05-11T23:28:38+00:00

This is not a connection timeout as a connection to the database is made

  • 0

This is not a connection timeout as a connection to the database is made fine. The problem is that the stored procedure that I’m calling takes longer than, say, 30 seconds and causes a timeout.

The code of the function looks something like this:

SqlDatabase db = new SqlDatabase(connectionManager.SqlConnection.ConnectionString);
return db.ExecuteScalar(Enum.GetName(typeof(StoredProcs), storedProc), parameterValues);

The ExecuteScalar call is timing out. How can I extend the timeout period of this function?

For quick stored procedures, it works fine. But, one of the functions takes a while and the call fails. I can’t seem to find any way to extend the timeout period when the ExecuteScalar function is called this way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T23:28:38+00:00Added an answer on May 11, 2026 at 11:28 pm

    If you are using the EnterpriseLibrary (and it looks like you are) try this:

     Microsoft.Practices.EnterpriseLibrary.Data.Database db = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase("ConnectionString");
     System.Data.Common.DbCommand cmd = db.GetStoredProcCommand("StoredProcedureName");
     cmd.CommandTimeout = 600;
     db.AddInParameter(cmd, "ParameterName", DbType.String, "Value");
    
     // Added to handle paramValues array conversion
     foreach (System.Data.SqlClient.SqlParameter param in parameterValues) 
     {
         db.AddInParameter(cmd, param.ParameterName, param.SqlDbType, param.Value);
     }
    
     return cmd.ExecuteScalar();
    

    Edited to handle the paramValues array directly based on the comments. I also included your ConnectionString value:

    Microsoft.Practices.EnterpriseLibrary.Data.Database db = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(connectionManager.SqlConnection.ConnectionString);
    System.Data.Common.DbCommand cmd = db.GetStoredProcCommand("StoredProcedureName", parameterValues);
    cmd.CommandTimeout = 600;
    return cmd.ExecuteScalar();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is a different question concerning: add a connection to database not working, asp.net
I call a stored procedure via Linq-to-SQL. This stored procedure simply processes data that
I have a stored procedure which is erroring with Timeout expired. The code involved
I'm receiving a database connection timeout error when my Domain Service is called to
This is a baffling one. My ASP.NET 3.5 app that was working fine suddenly
I have a stored procedure that executes much faster from Sql Server Management Studio
I am getting this exception: Collection was modified; enumeration operation may not execute. Directly
I'm currently struggling with this Collection was modified; enumeration operation may not execute issue.
This not a programming question but Most of the programmers using Eclipse should have
Why is this not compiling? error C2660: 'Concrete::WriteLine' : function does not take 1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.