SQL Server restore database progress...

  • Thread starter Thread starter Nathan Baulch
  • Start date Start date
N

Nathan Baulch

I have written a windows application that needs to perform an SQL Server
RESTORE.
Given that this process can take up to 5 minutes, I would like to monitor it
with a progress bar.
Is this possible using ADO.net or do I have to use the SQLDMO.Restore class?
I have tried using an SqlDataReader.Read() inside an infinite loop but no
data is ever returned.

Nathan
 
You need to have all of the open connections to a database closed to restore
it ...what are you doing with the SqlDataReader and the infinite loop?
 
You need to have all of the open connections to a database closed to
restore it

You misunderstand. It works as it should, it's just that I would like to
inform the user of its progress.
If you execute a RESTORE command in Query Analyzer, the following is
displayed on the screen on completion:

10 percent restored.
20 percent restored.
30 percent restored.
40 percent restored.
50 percent restored.
60 percent restored.
70 percent restored.
80 percent restored.
90 percent restored.
100 percent restored.
Processed 6416 pages for database 'mydb', file 'mydb' on file 1.
Processed 1 pages for database 'mydb', file 'mydb' on file 1.
RESTORE DATABASE successfully processed 6417 pages in 7.520 seconds
(6.989 MB/sec).

I need to get those messages as they occur during the process.
 
Is this possible using ADO.net or do I have to use the SQLDMO.Restore

Having a look at the SqlConnection.InfoMessage event, it is possible to get
the the progress messages from the server. Unfortunately all the messages
are lumped together and the event is only fired at the end of the RESTORE
operation.

So in conclusion I must assume that SQLDMO must be used if progress events
are required.
 
Back
Top