Example #1
0
        public static void RestoreBackup(string filePath)
        {
            try
            {

                string Query = string.Empty;
                Query = "USE [master]" + Environment.NewLine;
                Query += "ALTER DATABASE EBusiness" + Environment.NewLine;
                Query += "SET SINGLE_USER WITH" + Environment.NewLine;
                Query += "ROLLBACK IMMEDIATE" + Environment.NewLine;
                Query += "RESTORE DATABASE EBusiness FROM DISK = '" + filePath + "' WITH REPLACE" + Environment.NewLine;
                Query += "ALTER DATABASE EBusiness SET MULTI_USER" + Environment.NewLine;

                DataAccessManager dam = new DataAccessManager();
                //dam.ExecuteNonQuery(CommandType.Text, Query);
                dam.ExecuteNonQueryOnMaster(CommandType.Text, Query);
            }
            catch (Exception ex)
            {

                throw;
            }
        }