Link to home
Start Free TrialLog in
Avatar of Eamon
EamonFlag for Ireland

asked on

BACKUP DATABASE timeout expired.

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)

        Try

            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
                TempCnn.Open()
            End If

            cmdBU.ExecuteNonQuery()

        Catch ex As Exception

            MsgBox(ex.ToString)

        End Try

        TempCnn.Close()

    End Sub

My Stored Procedure is:

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

END

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?
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eamon

ASKER

Thanks Dhaest..

Seems to run fine now.