Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restore DB through Visual Basic causing errors

Status
Not open for further replies.

jstiegelmeyer

Programmer
Dec 31, 2002
27
US
Hello-

I am baffled, and I need help from someone who is smarter than me!

I am using a Visual Basic App to restore a backup db file to my SQL Server.

dbConn.Execute "RESTORE DATABASE MyDBName " _
& "FROM DISK = 'MyPath\MyFileName.bak' " _
& "WITH REPLACE"

dbConn is a different database than MyDBName, but within the same server. This usually works fine as long as there are no open connections to the database I am restoring.

This works for most of my clients, but I am consistently getting an error message from one of my clients. And I can't figure out what is different about their setup from the rest.

This is the error message:
"-2147217900, [Microsoft][ODBC SQL Server Driver][SQL Server]Processed 1112 pages for database 'MyDBName', file 'MyDBName_dat' on file 1."

After this occurs, the SA goes in and detaches the database and then reattaches it. After that is done, the problem is solved and the new db is restored.

Obviously, I would like to avoid this step. I would like to have the code work so that I don't require any human involvement.

Any help would be HUGELY appreciated!

Thanks,
Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top