When I use T-SQL in SSMS to restore a database with the STATS = 10
option (as per example below), I get statistics every 10 percent printed in the Messages window. I'm now wanting to automate the restore process (point a VB.Net WinForm application at a directory of backup and transactions files and let it restore all the data) and want to report the progress in a standard Windows form progress bar.
RESTORE DATABASE [Databasename] FILE = N'DatabaseName_dat' FROM DISK = N'S:\SQL\Backups\DatabaseName.bak' WITH FILE = 1, MOVE N'AuctionData_dat' TO N'C:\SQL\Data\DatabaseName.mdf', MOVE N'DatabaseName_log' TO N'C:\SQL\Logs\DatabaseName.ldf', NOUNLOAD, REPLACE, STATS = 10
I'm guessing I need to use some form of async command and wait for each response from the server to update the progress bar. So far all I've seen though are ExecuteReaderAsync, ExecuteNonQueryAsync and ExecuteScalarAsync commands - none of which return any details until the command has completely finished.
Is this even possible from .Net?
Thanks for any help or tips