none
System.Data.SqlClient.SqlException: Timeout expired RRS feed

  • Question

  • I get this exception while backing up a very large database (12GBytes). Other smaller ones, including one with 1.5Gb are saved OK. The ConnectionTimeout property is 15.

     

    How can I increase the timeout? It is read only, I think.

     

    System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
    The backup or restore was aborted.

     

    The code itself:

     

    using ( SqlConnection conn_histOHLC = new SqlConnection ( "server=ddmnvt61\\sqlexpress;" +
                                                                                                             "database=hist_OHLC;Trusted_Connection=Yes" ) )
                    {
                       
                        Console.WriteLine ( conn_histOHLC.ConnectionTimeout );
                        SqlCommand cmdm = new SqlCommand ( );
                        conn_histOHLC.Open ( );
                        cmdm.Connection = conn_histOHLC;
                        cmdm.CommandType = CommandType.StoredProcedure;
                        cmdm.CommandText = "backUphist_OHLC";
                        cmdm.Parameters.Clear ( );
                        cmdm.ExecuteNonQuery ( );
                    }

     

    Thanks.

    Saturday, July 21, 2007 4:50 PM

Answers

All replies

  • Hi there,
    You should be able to set your connection timeout in your connection string.

        connection timeout=30

    http://authors.aspalliance.com/aspxtreme/sys/data/sqlclient/SqlConnectionClassConnectionString.aspx

    Hope that helps.
    Sunday, July 22, 2007 3:17 AM
  •  nmadd wrote:
    Hi there,
    You should be able to set your connection timeout in your connection string.

        connection timeout=30

    http://authors.aspalliance.com/aspxtreme/sys/data/sqlclient/SqlConnectionClassConnectionString.aspx

    Hope that helps.

     

    Thanks, I've resolved it, actually. CommandTimeOut = 180 was what I needed. The backup time was 57 sec and the default was too short.

     

    Also the actual database size turned out to be 681 Mbyes not 12Gb. 12Gb is the final backuo .bak file. It is now actually 14Gbytes. Kind of scary.

    Sunday, July 22, 2007 3:29 PM
  • Code Snippet

    Also the actual database size turned out to be 681 Mbyes not 12Gb. 12Gb is the final backuo .bak file. It is now actually 14Gbytes. Kind of scary.



    You're probably appending each backup to the same file. So the backup file grows each time you backup by the size of the actual database.
    Thursday, July 3, 2008 9:28 AM
  •  minimalniemand wrote:
    Code Snippet

    Also the actual database size turned out to be 681 Mbyes not 12Gb. 12Gb is the final backuo .bak file. It is now actually 14Gbytes. Kind of scary.



    You're probably appending each backup to the same file. So the backup file grows each time you backup by the size of the actual database.

     

    Oh, yep. This is true. At that time it was new to me and I could not imediately grasp the concept. Now I am in a much better shape about everything, including the backup.

    Thursday, July 3, 2008 2:42 PM