Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

BACKUP DATABASE  timeout expired.

Posted on 2007-07-30
2
Medium Priority
?
740 Views
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)

        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?
0
Comment
Question by:Eamon
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 19591203
Try to add a timeout on your command-object

cmdBU.CommandTimeout = 120
0
 
LVL 1

Author Comment

by:Eamon
ID: 19591277
Thanks Dhaest..

Seems to run fine now.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

580 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