简体   繁体   中英

Problems with making backup with Firebird package

I'm trying to develop a backup with a firebird database using the firebird package but it gives me an error.

        FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
        cs.UserID = "SYSDBA";
        cs.Password = "masterkey";
        cs.Database = "C:\\Develop\\Database\\DB\\Database.fdb";

        FbBackup backupSvc = new FbBackup();

        backupSvc.ConnectionString = cs.ToString();
        backupSvc.BackupFiles.Add(new FbBackupFile(@"C:\\Develop\\Database\\DB\\Database.fbk", 2048));
        backupSvc.Verbose = true;

        backupSvc.Options = FbBackupFlags.IgnoreLimbo;
        backupSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);

        backupSvc.Execute();

I cant figure out why I can't compile the following statement: backupSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);

The errors are:

Error CS0246 The type or namespace name 'ServiceOutputEventHandler' could not be found (are you missing a using directive or an assembly reference?)

and

Error CS0103 The name 'ServiceOutput' does not exist in the current context

Is there anyone who can help?

It looks like you copied this example for version 2 of the Firebird ADO.net provider.

There are two problems:

  1. You missed copying the ServiceOutput method from that example

    static void ServiceOutput(object sender, ServiceOutputEventArgs e) { Console.WriteLine(e.Message); }
  2. The example is for a pretty old version of the Firebird ADO.net provider and no longer works for recent versions because the ServiceOutputEventHandler no longer exists in the Firebird ADO.net provider because that type of object is no longer necessary in C#.

    The solution is to change the line

    backupSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);

    to

    backupSvc.ServiceOutput += ServiceOutput;

As an aside, you can change new FbBackupFile(@"D:\Temp\Database.fbk", 2048) to new FbBackupFile(@"D:\Temp\Database.fbk") . Providing that length parameter is only necessary if you want to create a backup that is split across multiple files.

I found the answer now. My problem is that I have an old version (2.4) of firebird. I upgraded to version 2.9 - and everything works fine. So thank you so much for your assistance. You have all guidet me into the correct direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM