We help IT Professionals succeed at work.
Get Started

Timeout error occuring when running a SQL Restore script from web app

tatton777 asked
Last Modified: 2012-05-09

I'm running a program that creates new databases on the fly by restoring from a master.bak file. When I use this script against an unloaded database (empty tables) the script runs just fine. However, I now need it to restore a database that has some data in the tables. When I do this I get this error:

Encountered error while Creating Database Structure : Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. RESTORE DATABASE is terminating abnormally. 10 percent processed. 20 percent processed. 30 percent processed. 41 percent processed. 51 percent processed. 60 percent processed. 70 percent processed. 80 percent processed. 90 percent processed.

Here is the code that creates the restore sql code:

   string populateDb = "RESTORE DATABASE [" + txtDbName.Text.Trim() + "] " +
                        "FROM  DISK = N'C:\\Program Files\\Microsoft SQL Server\\" +
                        "MSSQL.1\\MSSQL\\Masters\\msf_school.bak' " +
                        "WITH  FILE = 1,  " +
                        "MOVE N'msf_school' TO N" +
                        "'C:\\Program Files\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\DATA\\" + txtDbName.Text.Trim() + ".mdf',  " +
                        "MOVE N'msf_school_log' TO N" +
                        "'C:\\Program Files\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\DATA\\" + txtDbName.Text.Trim() + ".ldf',  " +
                        "NOUNLOAD,  REPLACE,  STATS = 10";
Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE