Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Check file list inside a backup file Expand / Collapse
Author
Message
Posted Monday, August 25, 2014 3:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, August 25, 2014 3:47 AM
Points: 1, Visits: 2
I'm trying to get the list of database names / files from a backup file. Here's the code:

	''' <summary>
''' Prepare a RESTORE2 object.
''' </summary>
Private Shared Function CreateRestoreObject(filePath As String, Optional forRestore As Boolean = False) As SQLDMO.Restore2
Dim res As New SQLDMO.Restore2()

' What to restore
res.Action = SQLDMO_RESTORE_TYPE.SQLDMORestore_Database

' Input data
res.Files = "[" + filePath + "]"

' Protection (?) password
res.Password = SLQBackupPassword

If forRestore Then
res.ReplaceDatabase = True
res.PercentCompleteNotification = 10
End If

Return res
End Function

Dim objRestore = CreateRestoreObject(filePath)
Dim hdrList = objRestore.ReadBackupHeader(srv)
Dim nameList = GetQueryResultList(hdrList, "DatabaseName")

The code works fine on a SQL Server backup, but fails with a "***Password protected***" string on SQL Server Express backups. The corresponding SQL statement
RESTORE HEADERONLY FROM DISK = N'...' WITH  FILE = 1,  NOUNLOAD ,  PASSWORD = N'...'

works correctly. What am I doing wrong?
Post #1606999
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse