Click here to Skip to main content
12,447,275 members (60,059 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked

SQL Database Restore

, 1 Apr 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
T-SQL string maker for backup with a MEDIAPASSWORD database.


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)

        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;
            MessageBox.Show("Username/Password is null or empty!");
    catch (Exception ex)


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ahmet Göktaş
Software Developer Istanbul Bilgi University
Turkey Turkey
- Software developer from İstanbul/Turkey
- Programmed with C#.NET, ASP.NET, ASP, PHP, T-SQL
- SQL Server Administration
- Experiencing about NHibernate

You may also be interested in...


Comments and Discussions

GeneralYou can do better Pin
Donsw10-May-09 16:03
memberDonsw10-May-09 16:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160811.3 | Last Updated 1 Apr 2009
Article Copyright 2009 by Ahmet Göktaş
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid