Restore res = new Restore();

            this.Cursor = Cursors.WaitCursor;
            this.dataGridView1.DataSource = string.Empty;

            try
            {
                string fileName = this.txtFileName.Text;
                string databaseName = this.ddlDatabase.SelectedItem.ToString();

                res.Database = databaseName;
                res.Action = RestoreActionType.Database;
                res.Devices.AddDevice(fileName, DeviceType.File);

                this.progressBar1.Value = 0;
                this.progressBar1.Maximum = 100;
                this.progressBar1.Value = 10;

                res.PercentCompleteNotification = 10;
                res.ReplaceDatabase = true;
                res.PercentComplete += new PercentCompleteEventHandler(ProgressEventHandler);
                res.SqlRestore(srv);

                MessageBox.Show("Restore of " + databaseName +
                " Complete!", "Restore", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.progressBar1.Value = 0;
            }
        }

this is the error!!


tnx for helping im in rush

Recommended Answers

All 3 Replies

What version of SQL Server are you using?

MSSQL EXPRESS 2008 ..


Please help me ,

2008 doesn't support the method of backup/restore you are trying to use. You'll have to use a stored procedure to do what you want. They mention this here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.