BACKUP DATABASE  timeout expired.

Posted on 2007-07-30
Last Modified: 2008-01-09
I get this error message when  I try to run my BACKUP DATABASE Strored Procedure as a command in VS 2005.

Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

' Code
Dim strTempCnn As String = "user id=myUser;password=MyPassword;data source=MyServer;" & _
        "persist security info=True;initial catalog=MyDatabase;Connect Timeout=0"

        Dim TempCnn As SqlClient.SqlConnection = New SqlClient.SqlConnection(strTempCnn)


            Dim cmdBU As SqlClient.SqlCommand = New SqlClient.SqlCommand

            cmdBU.Connection = TempCnn
            cmdBU.CommandType = CommandType.StoredProcedure
            cmdBU.CommandText = "[dbo].[BackUpDataBase]"

            If TempCnn.State <> ConnectionState.Open Then
            End If


        Catch ex As Exception


        End Try


    End Sub

My Stored Procedure is:

TO DISK = N'c:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\MyDatabase.Bak'
   NAME = N'MyDatabase-Full Database Backup'    


However when i execute the Stored Procedure in SQL Server it executes fine and completes in 55 seconds.

Also in my connection string, I have changed the connect timeout property to various amounts and still get same error message.

Any ideas?
Question by:Eamon
    LVL 53

    Accepted Solution

    Try to add a timeout on your command-object

    cmdBU.CommandTimeout = 120
    LVL 1

    Author Comment

    Thanks Dhaest..

    Seems to run fine now.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    27 Experts available now in Live!

    Get 1:1 Help Now