con.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=Database1;Integrated Security=True;User Instance=True";
con.Open();
cmd.CommandText = @"restore database Database1 from disk ='d:\\MyDatabaseBackup.bak'";
cmd.Connection = con;
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
con.Close();
MessageBox.Show("Restore COMPLETE");
This code has no error. It Pop up Restore complete.
1)I want to extract mdf file from the backup file at specified location.(How can i specify the destination location in sql command )
2)above code runing properly means no error, but i don't know where the database is restored.
and i notice one thing here that, it's only successfull(means message box show Restore complete) to restore the database if the project from which backup my database is on it's same location