locked
Error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. RRS feed

  • Question

  • User1309403994 posted
    I just started to get the above error all of a sudden during the bulk import.  I was importing pictures all day and all of a sudden, I started getting this error message and I cannot import a single picture any more.  My web application timeout is set to 3000, but it times in less than a minute.  The culprit seems to be the AddPhoto function.  I restarted SQL Server 2000, IIS, and the whole machine, but to no avail.  There's no code change since it was working earlier in the day.  Any ideas?

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
    The statement has been terminated.

    Source Error:

    Line 125:        command.Parameters.Add(New SqlParameter("@BytesPoster", ResizeImageFile(BytesOriginal, 198)))
    Line 126:        command.Parameters.Add(New SqlParameter("@BytesThumb", ResizeImageFile(BytesOriginal, 100)))
    Line 127:        command.ExecuteNonQuery()
    Line 128:    End Sub
    
    Tuesday, July 19, 2005 9:41 PM

All replies

  • User1309403994 posted
    I forced a close of the connection and it seems to resolve the problem.
    Thursday, July 28, 2005 3:22 PM
  • User-2066645462 posted

    Hi,

    I am also getting the same error. Time out expired. the timeout period elpased prior to the completion of the operation.....

    Actually, I am trying to run a data migration tool to transfer the data from one big table to multiple tables...

    there are around 5000-10000 records.... the program starts giving error after some 3000 records... and then it does not migrate even a single record if I start the tool again..

    I have tried everything... checkin the locks.... blocking.... connection pooling... etc etc...

    but nothing seems to be working

    Please help me in this...

    Thanks in advance..

    Tuesday, August 16, 2005 11:48 AM
  • User1309403994 posted
    I'm back to where I started with this.  After implementing the manual closing of the connections, I got a few more uploads in, but now I'm stuck again.  There's something fundementally wrong with this...
    Tuesday, August 16, 2005 5:20 PM
  • User-1941589572 posted
    I'm getting the same problems.....I even set the

    CommandTimeout = 120 in the connection string and it still gets the error

    Thursday, August 18, 2005 12:34 PM
  • User-1941589572 posted
    Try adding a Connect Timeout in the web.config

    <add key="DBConnection" value="server=LocalHost;uid=sa;pwd=;database=DataBaseName;Connect Timeout=200; pooling='true'; Max Pool Size=200"/>

    Please reply back if this works....

    Thursday, August 18, 2005 2:59 PM
  • User1309403994 posted
    Same results for me.
    Thursday, August 18, 2005 3:19 PM
  • User-1941589572 posted
    Did you set the CommandTimeout  in your code behind also when you call the connection string...
    Thursday, August 18, 2005 3:32 PM
  • User1309403994 posted

    Well, I had not set it, but now that I have it seems to work.  What's taking so long to process these requests?  Do you think it's related to database optimization problems?

    In any case, thanks a lot for your help.  It's a relief to have the Import capability back in action.

    Thursday, August 18, 2005 4:01 PM
  • User-1941589572 posted
    I would run your SQL in query analizer and see how many seconds it takes for each set.  Then debug your code from there to see if you have any issues elsewhere.  For me it was the SP, running 45 seconds.... 
    Thursday, August 18, 2005 4:03 PM
  • User-1251924073 posted

    Hai ......,

                   I 'm also getting the same problem. I 'm inserting 5 records to 4 tables (2 in 1 table and then 1 each in other tables). When trying to insert the 2nd record to the table, I get this error. How can I solve this problem.

    Wednesday, September 21, 2005 8:33 AM
  • User-2137710262 posted
    I don't know if you still have this problem or not, but I had it, and finially solved it.  When you read the documentation, if you set the CommandTimeout on the connection object it is NOT inherited by the command object.  You have to set the commandtimeout property of the SQLdata adapter, in the Select Command subset property.  I set it to zero, this means it will wait until it is done. This could mean a long wait for anyone waiting on the data, so you might not want to set it zero like I did.

    Thanks -

    Michael White
    Thursday, December 1, 2005 8:25 AM
  • User599569818 posted

    Hi

    Same as Michael White.

    Solved it by setting the timeout property to command object
     

    Tuesday, February 27, 2007 3:56 AM
  • User870638558 posted

     I'm having the same problem but I'm trying to edit someone elses code.  Can anyone help me with this?  Where would I set the connection timeout to 0 in the function below? 

    Thanks...

     

     

    Private Function Data2Array() As Array
            Try
                If (dbConnection.State = ConnectionState.Closed) Then dbConnection.Open()
    
    
                'select count(*) from TimesheetStudentActions where stuAction='feedback'
                Dim dTable As New DataTable("temp")
                Dim dtAdapter As New SqlDataAdapter("SELECT  SECTIONID,SCHLSTUID,convert(varchar(10),cast(DAYACCESSED as dateTime),101), " & _
                " ACTIONID, DATEPART(ww,convert(varchar(10),cast(DAYACCESSED as dateTime),101)) WeekOfYear, " & _
                " DATEPART(dw,convert(varchar(10),cast(DAYACCESSED as dateTime),101)) DayOfWeek FROM " & _
                " TimesheetStudentActions WHERE stuAction <> 'feedback' AND  IsNull(ynPROCESSED,0) = 0 AND SCHLSTUID IN (SELECT SCHLSTUID From TimesheetStudent)", dbConnection)
                dtAdapter.Fill(dTable)
    
                Dim intArraycounterMax As Integer = dTable.Rows.Count - 1
                Dim intFieldcounterMax As Integer = dTable.Columns.Count - 1
                Dim intFieldcounter As Integer
                Dim MyArray(intArraycounterMax, intFieldcounterMax) As String
                Dim intarraycounter As Integer = 0
                Dim dRow As DataRow
                For Each dRow In dTable.Rows
                    For intFieldcounter = 0 To intFieldcounterMax
                        Try
                            MyArray(intarraycounter, intFieldcounter) = dRow(intFieldcounter)
                        Catch ex1 As InvalidCastException
                            ' Nothing to do Nulls are ok 
                        Finally
                        End Try
                    Next
                    intarraycounter += 1
                Next
                Return (MyArray)
            Catch ex As Exception
                WriteToLogFile("Exception: " + ex.Message + ex.StackTrace, sImportErrorFile)
            Finally
                If Not (dbConnection Is Nothing) Then
                    If (dbConnection.State = ConnectionState.Open) Then
                        dbConnection.Close()
                    End If
                End If
            End Try
        End Function
     
    Thursday, March 8, 2007 12:55 PM
  • User-464838050 posted

    The solution is simple, change the CommandTimeout property of your SqlCommand object.

     The Connect Timeout attribute of a connection string determines how long a SqlConnection Object runs before it stops attempting to connect to a server.

     

    -Nuno

    Monday, March 19, 2007 2:30 PM
  • User320960288 posted

    This solution is work for me..

    thanks a lot.

    Tuesday, July 3, 2007 6:22 AM
  • User-691607848 posted

    I'm having the same problem. i have already set "Connect Timeout=0"... and my query when running in query analyzer takes only 7 secs.. shouldn't that be fast enough? 

     pls help...

     

    thanks..
     

    Sunday, July 29, 2007 9:33 PM
  • User1898588388 posted

    Thanks the command timeout=0 did the trick!

    Tuesday, November 6, 2007 12:25 PM
  • User597752282 posted

    I got the same error executing a complicated stored procedure from my VB.NET application.  However, rather than setting the command timeout = 0 which the documentation said is "not recommended," I just chose a longer interval of time.

    MyCmd.CommantType = CommandType.StoredProcedure

    MyCmd.CommandTimeout = 300              ' 5 minutes

    MyCmd.ExecuteNonQuery

     This solved the problem. 

    Wednesday, November 28, 2007 11:20 PM
  • User-500009581 posted

    I am getting the same error too. The CommandTimeout is set to 30, which isn't probably a lot, but all I am doing is updating one record and then inserting 4 new records. It's being done with different SqlCommand and SqlConnection objects, so kinda unrelated. Two statements go one after another and take less then a second in Query Analyzer. What is strange is that if the update/insesrt fails in aplication and I will try exact same statement in Query Analyzer it may take 3-5 minutes to execute (different time every time), but once it's complete, and I try it again it takes less then a second. Also what is strange, it is absolutely inconsistent. It may complete ok one time (or even several) and then next time times out on update or finish update but fails the insert.

    Any ideas. Please advise. Thanks.

    Thursday, January 24, 2008 3:26 PM
  • User2120078098 posted

    HI,

    I am facing the same problem.

    My project is on .Net with SQL Server.

    I am trying to retrieve a huge data at a time from DB. Previously it is working fine.

    From three days back i am getting  "Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."

    Even i made some changes to solve that

     in web.config i put "connect timeout = 300000" and

         CommandTimeout = 300000     (previously they are 10000)                         // 300000 = 5min

     still i am facing the same problem..

    Can any one say solution for this

    Regards,

    Venkatesh 

    Wednesday, March 5, 2008 11:25 PM
  • User870638558 posted

    I added the code below to the web.config file and it worked.  I found that there are two things that can time out.  The SQL call can time out and the application that is running can time out.

    <system.web>
                <customErrors mode="Off"/>
                <httpRuntime appRequestQueueLimit="100" executionTimeout="60000" />
            </system.web>

     

    Hopefully this works!

    Tuesday, March 11, 2008 3:48 PM
  • User1757986464 posted
    Here is the best solution

    objCommand.CommandTimeout = 0

    When 0 is for no limit. 

     

    Monday, March 31, 2008 6:46 AM
  • User338880739 posted

    I am getting this error inside the preview data window when selected from the dataset. How or where to I change the timeout setting?

    Wednesday, April 9, 2008 9:26 PM
  • User671909081 posted

    <add key="DBConnection" value="server=LocalHost;uid=sa;pwd=;database=DataBaseName;Connect Timeout=200; pooling='true'; Max Pool Size=200"/>
     

    This is working for me :) thank you.

    Sunday, April 20, 2008 2:24 AM
  • User-83546127 posted

     

    set the command.connectiontimeout property to maximum integer value

    it will solve the problem

     

    Wednesday, April 23, 2008 5:10 AM
  • User636866211 posted

    'Sample code that has solved a similar problem for me:

    Dim myCommand As New SqlCommand(sql, myConnection, myTrans)

    myCommand.CommandType = CommandType.StoredProcedure

    myCommand.CommandTimeout = 0

    'Solve the problem at run time

    Tuesday, June 3, 2008 8:35 AM
  • User1354121570 posted

     

    Thanks every body the solutions were very helpfull

    CmdGenCls.CommandTimeout = 300       worked for me

     Regards

    Sara

    Monday, June 16, 2008 3:23 AM
  • User830945118 posted

    thanks for your solution on command timeout=0 it works for me :-)

    Tuesday, July 15, 2008 3:33 AM
  • User-384620377 posted

    When I run my ASP.NET 2.0 web app on my dev machine it works perfect.

    When I precomile it to my web deployment project and then copy the debug files to my web server I get this message in the middle . The Error is

    Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Error Stack : at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoLoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames) at Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames) at Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(DbCommand command, DataSet dataSet, String tableName) at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteDataSet(DbCommand command) at DAL.OrderForms_DAL.GetTemplatesByTemplateID_DAL(Int32 OrgID, Int32 ClientId, Int32 TemplateID)

    I changed the connection string to 120 I am tracing session time out also, But it was not worked for me.

    I am getting this type of different errors every time, when i using the website. 

    Please suggest me to find out the error? Thanks Advance

    Thursday, August 14, 2008 12:36 PM
  • User1305936220 posted

    Will this solution of setting CommandTimeout  property of SqlCommand object to some value work if there are around 4 threads trying to execute the database query parallely????? I mean won't it make the process of executing the queries at a slower rate??

     Prashant Koli

    Software Engineer

    Monday, August 18, 2008 8:36 AM
  • User803071821 posted

    Hi Folks..really it's very nice code and very helpful i wud like thanks to the guy given this code...

    bye..bye

     

    Thursday, August 21, 2008 11:20 AM
  • User-1948399394 posted

     command timeout=0 doesn't work for me [:(]

    Friday, September 19, 2008 4:05 PM
  • User723642434 posted

    It dosen't work

    Saturday, October 4, 2008 3:34 AM
  • User-1143550182 posted

    Is this running inside a transaction? 

    Monday, October 6, 2008 12:21 PM
  • User-992604473 posted

     Excellent answer, sorted my problem.

    Wednesday, October 22, 2008 11:15 PM
  • User-1436512885 posted

     

    Is this running inside a transaction? 

    Thanks for asking this. In my case there are transactions involved, although the query that causes the error isn't in one. I'm running unit tests inside Visual Studio that contact the DB and use transactions to not modify the DB. I'm using typed datasets (unfortunately). For the calls that only get data, I'm not wrapping them in a TransactionScope. For things that do, I am. Thanks.

    Tuesday, December 9, 2008 12:10 PM
  • User-1436512885 posted

    Actually, I'm just an idiot. For my problem, I was starting a transaction on test class initialize and rolling it back on test class cleanup, but the cleanup method wasn't being called when all the tests in the class had been run so some tables were locked and caused (I'm assuming) other tests to deadlock and throw this timeout expired error.

    Maybe not exactly like everyone else's issue, but this could be something to look out for if your getting this error.

    Tuesday, December 9, 2008 12:40 PM
  • User-59324778 posted

    Nuno said :

    The solution is simple, change the CommandTimeout property of your SqlCommand object.

     

     

    I TRY AND IT WORK !!!

    Monday, December 22, 2008 8:51 AM
  • User-379011848 posted

    I tried that and got a different error: Time-out occurred while waiting for buffer latch type 4 for page (1:180), database ID 6.

    Wednesday, January 14, 2009 10:16 AM
  • User-140528697 posted

    Hi All,

    I get this error when i am uploading a file, It times out within 35 secs.
    Works fine at the development server but not on the Pre-Prod .
    Can anyone suggest me as to what could be the problem ??

    Regards,

    Francis P.

     

     

     

    Wednesday, March 4, 2009 3:15 AM
  • User751017454 posted

    I am getting this error when ASP.NET tries to read/write from session. I am using SQLExpress for session provider with following in my web.config.

    <sessionState mode="SQLServer" allowCustomSqlDatabase="false" cookieless="false" timeout="20" sqlConnectionString="data source=XXXURLXXX\SQLEXPRESS;user id=yyy;password=zzz"/>

     Note webserver and sqlexpress are two different servers with firewall in between.

     Any clue or help is appreciated.

    Thanks!

    Friday, April 17, 2009 9:42 AM
  • User-1131243847 posted

    I was getting the same error [may be due to some heavy load process is happening on DB, but still my query/sp runs with excellent speed, but all these commandtimeout settings, I doubted, as it requires more understanding the effects of changing.

    but I solved the error by keeping

    WITH (NOLOCK)  option for every table name mentioning... it works like Magic!

    for ex: select * from Employee e WITH (NOLOCK)

    Tuesday, June 16, 2009 8:02 AM
  • User-313655253 posted

    Try This

    Please note the commandTimeout property

    -Prasannakumaran Sarasijanayanan 

     

    Dim ObjConn As System.Data.SqlClient.SqlConnection

    Dim Dt As New Data.DataTable ObjConn = New Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings.Item("Connectionstring").ConnectionString)

    If ObjConn.State = Data.ConnectionState.Closed Then

    ObjConn.Open()

    End If

    Dim Da As New Data.SqlClient.SqlDataAdapter("SELECT * FROM...", ObjConn)

    Da.SelectCommand.CommandTimeout = 3000

    Da.Fill(Dt)

    Thursday, June 18, 2009 10:04 AM
  • User-2097060974 posted

    I had this happen to me in SQL Server directly, using Design View on my table.  I could make my change (which was to the width of an nvarchar field), but when I went to save it, that's when I'd get this error.  The table itself wasn't even open when the error occurred, so that wasn't it.  So I tried a SQL query and that worked (ALTER TABLE mytable ALTER COLUMN myColumn nvarchar(newWidth)).  I checked Design View and it showed it worked.  I changed it back to the old value in Design View and tried saving it - same error again.

    I figured it had to do with the fact I have 3 million records and how long it must take to update them all.  I had "Remote query timeout", in the Connections window on the SQL Server Properties dialog, set to 0, which should've meant an unlimited period, but it didn't.  I set this to 1200 and magically it saves my new field width for the column I wanted to change.  Hope this helps someone.

    -Tom

    Thursday, July 16, 2009 5:48 PM
  • User-1082374796 posted

    I wrote Connect Timeout upto 2000 but no change.

    Wednesday, August 19, 2009 5:20 AM
  • User-1034268908 posted

     The post is 5 years old but I ran into this with a DNN site and there were a few things to correct:

    1) Sign in to Sql 2008 Exp as SA and make sure the timeout is adequate -- it was, at 600 seconds.

    -- I also had a permissions issue with dropping indexes and re-adding them for what I was doing so there was more to do than just this.  This error was the last thing to fix.

    2) Tried the webconfig setting in the connection string but this didn't fly.

    3) I'm working in Visual Studio so I highlighted the connection, selected Modify Connection | Advanced and sure enough ... there's a default timeout set for 15 seconds.

    Having already tested my query for deleting a very huge file, I know it takes just over 2 minutes.  Setting the timeout in visual studio (db connection advanced tab) also for 600 seconds seems to have worked.

    So if anyone else sees this, here's another solution.  A time warp would have been the best answer so that anyone from 2005 forward would have already seen this link. Cool

    Friday, August 21, 2009 12:26 PM
  • User1349802433 posted

    WITH (NO LOCK)


    This worked perfectly for me. Thanks :)

    Thursday, September 17, 2009 9:12 AM
  • User716575569 posted

    I'm using VS 2005.  My project incorporates a Business Logic Layer and a Data Access Layer.  The Table Adapter in the DAL is configured to run a stored procedure in SQL Server 2005. If the web application were to run to completion, the stored procedure would add about 500 rows to an existing table in SQL.  When I run the sproc in SQL Server Management Studio, it takes about 45 seconds to complete. When I run my app on localhost, it throws the Timeout exception after 30 seconds.  I've tried all the suggestions posted here (except the WITH (NOLOCK) because the sproc has 20 tables and several subqueries in it) and no matter what I have tried, the exception pops up after 30 seconds. 

    Here's the stack trace & I've highlighted where it blows up:

    [SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +862234
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739110
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1956
       System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
       System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +903
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
       System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
       SunwestODSTableAdapters.RentRateTableAdapter.sw_ProcessResidentRentIncreases(Nullable`1 NotificationMonth) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\rentmgmt\86e70563\dc6a7260\App_Code.989tz2lc.4.cs:6276
       RentRateBLL.sw_ProcessResidentRentIncreases(Int32 month) in i:\IT\Applications\Rent Management\RentMgmt\App_Code\BLL\RentRateBLL.cs:89
       ResidentData_CalculateResidentRentIncreases.CalculateRents_Click(Object sender, EventArgs e) in i:\IT\Applications\Rent Management\RentMgmt\ResidentData\CalculateResidentRentIncreases.aspx.cs:27
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

    Help!

    Friday, September 25, 2009 4:45 PM
  • User-1998035970 posted

    Thanks Man, I also got the same issue while running a windows application. After i set command timeout it works fine.

    Roopesh

    Thursday, October 22, 2009 2:56 PM
  • User1147484247 posted

    Hi,

    set objConnection.CommandTimeout = 0;

    thanks

    nikunj mochi

    Thursday, November 5, 2009 4:53 AM
  • User-1252206308 posted

    can use

    For a command

    Command.CommandTimeout=90//time in sec's

    Globally for the application

    server=server_name;initial catalog=DB Name;connect timeout=45;

    in the connection string section of your config file.


    Thursday, November 5, 2009 8:14 AM
  • User1407680107 posted

    I was having this problem with my own DNN website as well.  This one bit of functionality would spin for about 30 seconds and then throw the good ol SQL timeout exception...

    "The post is 5 years old but I ran into this with a DNN site and there were a few things to correct:

    1) Sign in to Sql 2008 Exp as SA and make sure the timeout is adequate -- it was, at 600 seconds."

    This can be found by logging into your SQL server as SA, right clicking on the root(machine name) and selecting properties...you should see Connections under the 'select a page' menu.  Towards the bottom you will see 'Remote Query timeout (in seconds, 0 = no timeout)

    Mine was indeed set to 600...but was clearly not working...so I set it to 0 and poof!  The problem dissappeared!!

    Friday, December 4, 2009 4:48 PM
  • User364671509 posted

    just below your Dim dtAdapter As New SqlDataAdapter.

    add this:

     

    dtAdapter.SelectCommand.CommandTimeout = 0

     

    hope this helps

    Wednesday, February 17, 2010 11:20 AM
  • User364671509 posted

     If you are using a SqlDataSource Control add a selecting event by double clicking the selecting event in the properties window.

    now add the following code to the event:

    C# example:

    protected void SqlDataSource1_Selecting(object sender,SqlDataSourceSelectingEventArgs e)

    {

                e.Command.CommandTimeout = 0;

    }

    Hope this helps,

    Jay

    Thursday, February 18, 2010 10:23 AM
  • User1734892334 posted

    I would say that setting Connection timeout in web.config and  CommandTimeout of the SqlCommand object are right points but one more thing should be set beside that - this is the executionTimout of the requiest. If the execution timout is smaller than the connection timout you will not be able to get the response incuding the results. So set the execution timeout this way:

    <httpRuntime executionTimeout="36000" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />

     

    The timeout is defined in seconds so set it appropriate for you.The httpRuntime element is located in system.web.

     

    Happy programming!

     

    Monday, March 1, 2010 3:10 AM
  • User1390648284 posted

    Where do you put this code?  getting a little mixed up. sorry

    Tuesday, September 14, 2010 1:34 PM
  • User-475715802 posted

    Jay's solution worked for me.  I could not figure out where to put the CommandTimeout statement into my code!  Here is what I did for VB in Visual Studio 2005, it goes in my (pagename?).aspx.vb file:

    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting


            e.Command.CommandTimeout = 0


        End Sub

    I did this by just double clicking my SqlDataSource object on the webpage.

    Hope this helps and thanks Jay!

    Bill


     If you are using a SqlDataSource Control add a selecting event by double clicking the selecting event in the properties window.

    now add the following code to the event:


    C# example:

    protected void SqlDataSource1_Selecting(object sender,SqlDataSourceSelectingEventArgs e)

    {


                e.Command.CommandTimeout = 0;

    }

    Hope this helps,

    Jay


    Wednesday, December 8, 2010 11:09 AM
  • User-1098477745 posted

    Although the procedure sets the transaction isolation level to read uncommitted, you still have to use WITH (NOLOCK) on the tables in the dynamic query.  if you do it in your dynamic query, it will work fine.

    Wednesday, December 15, 2010 5:19 PM
  • User133278714 posted

    I'm so glad this post was here, my problem which was mentioned above was that i had a transaction open and i opened another transaction in a different class, but the first transaction was holding the connection stopping the other statement from being executed. Sorted that out and it was problem solved. Thanks guys.

    Thursday, February 24, 2011 4:52 AM
  • User-1069616273 posted

     I have seen MANY threads on this topic, but still can not find a definitive answer as to how to fix this, using an ObjectDataSource instead of a SQLDataSource

    I am using VB.Net

    1) I have a DAL(we will call it dal.xsd) made up of a TableAdapter (we will call it getsomething)

    2) The getsomething TableAdapter has a query which calls a stored procedure (we will call it sp_getsomething)

    3) I have a webpage(getsomething.aspx) which has a GridView(gdvGetSomething) whos data source is an ObjectDataSource(ObjectDataSource1), which calls the sp_getsomething stored procedure from the getsomething TableAdapter

    PROBLEM:  The execution of the stored procedure takes longer than the default command timeout of 30 seconds

    Question: How and/or where can I raise the Command Timeout value so that I dont get the System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

    I have read several things about creating a partial class, and if this is the case, then where do I put that at?  Do I have to create a new class file?  does it go in the getsomething.vb?  Is there an entry I can put in the web.config?

    Any help would be greatly appreciated.  Thanks!

    Wednesday, March 9, 2011 10:38 AM