Click here to Skip to main content
15,173,474 members
Home / Discussions / C#
   

C#

 
AnswerRe: MDI Parent in C# Pin
Ingo12-Sep-12 23:49
MemberIngo12-Sep-12 23:49 
GeneralRe: MDI Parent in C# Pin
Zeyad Jalil12-Sep-12 23:58
professionalZeyad Jalil12-Sep-12 23:58 
AnswerRe: MDI Parent in C# Pin
Ingo13-Sep-12 2:04
MemberIngo13-Sep-12 2:04 
GeneralRe: MDI Parent in C# Pin
BobJanova13-Sep-12 5:31
MemberBobJanova13-Sep-12 5:31 
AnswerRe: MDI Parent in C# Pin
Ingo13-Sep-12 5:15
MemberIngo13-Sep-12 5:15 
AnswerRe: MDI Parent in C# Pin
Pete O'Hanlon13-Sep-12 5:31
mvaPete O'Hanlon13-Sep-12 5:31 
AnswerRe: MDI Parent in C# Pin
BillWoodruff17-Sep-12 7:27
mveBillWoodruff17-Sep-12 7:27 
QuestionBackUp And Restore of SqlServer 2005 using C# Windows Application Pin
NABIN SEN12-Sep-12 20:14
MemberNABIN SEN12-Sep-12 20:14 
Some One Plz Help Me
When i Am trying to Restore a database it gives me error-
SQL
System.Data.SqlClient.SqlException: Logical file DB_Jaggry is not part of database DB_Jaggry_Restore&. Use RESTORE FILELISTONLY to list the logical file names.
RESTORE DATABASE is terminating abnormally

C#
private void button1_Click(object sender, EventArgs e)
       {
           BackupDB(@"C:\TempDB_Jaggry.bak");
           RestoreDB(@"C:\TempDB_Jaggry.bak", "DB_Jaggry_Restore");
       }

Code fro Backup-
 public static void BackupDB(string backupDestinationFilePath)
        {
            try
            {
               // Console.WriteLine("Backup operation started");
                Backup backup = new Backup();
                //Set type of backup to be performed to database
                backup.Action = BackupActionType.Database;
                backup.BackupSetDescription = "BackupDataBase description";
                //Set the name used to identify a particular backup set.
                backup.BackupSetName = "Backup";
                //specify the name of the database to back up
                backup.Database = "DB_Jaggry";
                //Set up the backup device to use filesystem.
                BackupDeviceItem deviceItem = new BackupDeviceItem(
                                                backupDestinationFilePath,
                                                DeviceType.File);
                backup.Devices.Add(deviceItem);

                // Setup a new connection to the data server
                ServerConnection connection = new ServerConnection();               
                Server sqlServer = new Server(@"SNEHA-PC\SQLEXPRESS");
                //Initialize devices associated with a backup operation.
                backup.Initialize = true;
                backup.Checksum = true;               
                backup.ContinueAfterError = true;               
                backup.LogTruncation = BackupTruncateLogType.Truncate;                
                backup.SqlBackup(sqlServer);
               MessageBox.Show("Backup operation succeeded");
            }
            catch (Exception ex)
            {
                //Console.WriteLine("Backup operation failed");
               // Console.WriteLine(ex.Message);
                MessageBox.Show(ex.ToString());
            }           
        }

Code For Restore-
 public static void RestoreDB(string backUpFilePath, string databaseName)
        {
        try
        {            
            Restore restore = new Restore();            
            restore.Database = databaseName;
            
            restore.Action = RestoreActionType.Database;                 
            restore.Devices.AddDevice(backUpFilePath, 
DeviceType.File);           


            restore.ReplaceDatabase = true;            
            restore.NoRecovery = false;
            restore.RelocateFiles.Add(new RelocateFile("DB_Jaggry",@"C:\Temp\DB_jaggry.mdf"));
           restore.RelocateFiles.Add(new RelocateFile("DB_Jaggry_Log",@"C:\Temp\DB_Jaggry_Log.ldf"));
            ServerConnection connection = new ServerConnection(@"SNEHA-PC\SQLEXPRESS");
            Server sqlServer = new Server(connection);
            restore.SqlRestore(sqlServer);
            MessageBox.Show("Restore operation succeeded");
        }
        catch (Exception ex)
        {
            
            MessageBox.Show(ex.ToString());
        }        
    }

Thnk u In Advance...

AnswerRe: BackUp And Restore of SqlServer 2005 using C# Windows Application Pin
Roger Wright12-Sep-12 21:28
professionalRoger Wright12-Sep-12 21:28 
QuestionFirst real C# program by C++ developer Pin
PapaGeek12-Sep-12 17:27
MemberPapaGeek12-Sep-12 17:27 
AnswerRe: First real C# program by C++ developer Pin
Roger Wright12-Sep-12 21:21
professionalRoger Wright12-Sep-12 21:21 
GeneralRe: First real C# program by C++ developer Pin
BobJanova13-Sep-12 0:07
MemberBobJanova13-Sep-12 0:07 
GeneralRe: First real C# program by C++ developer Pin
jschell13-Sep-12 9:28
Memberjschell13-Sep-12 9:28 
AnswerRe: First real C# program by C++ developer Pin
V.12-Sep-12 21:30
professionalV.12-Sep-12 21:30 
AnswerRe: First real C# program by C++ developer Pin
Richard MacCutchan12-Sep-12 23:26
mveRichard MacCutchan12-Sep-12 23:26 
AnswerRe: First real C# program by C++ developer Pin
jschell13-Sep-12 9:59
Memberjschell13-Sep-12 9:59 
AnswerRe: First real C# program by C++ developer Pin
wizardzz13-Sep-12 11:46
Memberwizardzz13-Sep-12 11:46 
AnswerRe: First real C# program by C++ developer Pin
Alan Balkany13-Sep-12 12:10
MemberAlan Balkany13-Sep-12 12:10 
AnswerRe: First real C# program by C++ developer Pin
Alan Balkany13-Sep-12 12:44
MemberAlan Balkany13-Sep-12 12:44 
QuestionDynamic TimeSlots Pin
Member 941347212-Sep-12 9:34
MemberMember 941347212-Sep-12 9:34 
AnswerRe: Dynamic TimeSlots Pin
Pete O'Hanlon12-Sep-12 10:46
mvaPete O'Hanlon12-Sep-12 10:46 
QuestionSieve of Eratosthenes Pin
WebMaster12-Sep-12 5:23
MemberWebMaster12-Sep-12 5:23 
AnswerRe: Sieve of Eratosthenes Pin
fjdiewornncalwe12-Sep-12 5:31
professionalfjdiewornncalwe12-Sep-12 5:31 
AnswerRe: Sieve of Eratosthenes Pin
Manfred Rudolf Bihy12-Sep-12 5:36
professionalManfred Rudolf Bihy12-Sep-12 5:36 
GeneralRe: Sieve of Eratosthenes Pin
WebMaster12-Sep-12 5:39
MemberWebMaster12-Sep-12 5:39 

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.