Introduction
This application is third party tool for creating T-SQL scripts for database restore operations.
You can restore a database from the SQL Server Management Studio GUI, but you cannot restore a protected backup file with MEDIAPASSWORD! In that case, you must write a SQL string, but that is very boring.
This tool gives you a chance to make a SQL string quickly, and you can make a differential restore string. This application stores your connection info in an XML file.
Using the code
This code shows you the backup file's appends:
private void btnSelectDiffFile_Click(object sender, EventArgs e)
{
try
{
isConnected();
if (_isConnected & server != null & !string.IsNullOrEmpty(_remoteUser)
& !string.IsNullOrEmpty(_remotePass))
{
string cUser = _remoteUser != null ? _remoteUser : string.Empty;
string cPass = _remotePass != null ? _remotePass : string.Empty;
FileSelectDialog fileselect = new FileSelectDialog();
DialogResult result = fileselect.ShowDialog(server,cUser,cPass);
if (result == DialogResult.OK)
{
string backtoLocalName = fileselect.Show();
backtoLocalName = backtoLocalName.Replace("$", ":");
backtoLocalName = backtoLocalName.Replace(_serverName != null ?
_serverName : string.Empty, string.Empty);
backtoLocalName = backtoLocalName.Replace("\\\\\\", string.Empty);
txtDiffFile.Text = backtoLocalName;
Restore res = new Restore();
res.Devices.AddDevice(backtoLocalName, DeviceType.File);
DataTable dt = res.ReadBackupHeader( server );
CreateTextBoxColumn( grdDiffBackups, "BackupName", "BackupName" );
CreateTextBoxColumn( grdDiffBackups, "Position", "Position" );
CreateTextBoxColumn( grdDiffBackups, "BackupStartDate",
"BackupStartDate" );
grdDiffBackups.AutoGenerateColumns = false;
bsDiff.DataSource = dt;
grdDiffBackups.DataSource = bsDiff;
}
}
else
{
MessageBox.Show("Username/Password is null or empty!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}