1

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?

Michael Eriksen
  • 167
  • 1
  • 3
  • 13

2 Answers2

0

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.

Arioch 'The
  • 15,799
  • 35
  • 62
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Thank you so much! It makes sense! But what about ServiceOutput is this a method call? If so how can I write this method correctly? I have tried with `private void ServiceOutput(object sender, ServiceOutputEventArgs e)`. But when I call `backupSvc.Execute();` I got the error: "FirebirdSql.Data.FirebirdClient.FbException: 'unrecognized service parameter block'. I don't know why I got this error too. Thanks in advance for any help. " – Michael Eriksen Nov 03 '19 at 16:30
  • @MichaelEriksen The error has nothing to do with the `ServiceOutput` method. Which Firebird version are you using? – Mark Rotteveel Nov 03 '19 at 18:23
  • @MichaelEriksen SPB is firebird's internal structure. Maybe (or maybe not) you try to pass some new flag to some old version of Firebird that did not know that flag yet. – Arioch 'The Nov 03 '19 at 18:34
  • @MarkRotteveel I'm using 2.5 – Michael Eriksen Nov 03 '19 at 21:40
  • @Arioch'The Thanks for answering. But which flag is the possibilities? – Michael Eriksen Nov 04 '19 at 19:47
  • @MichaelEriksen frankly, I think you'd better ask it in Net Provider support forum, u may take link in the tag description. Mr. Cincura is rare guest on SO and while I comparing SPB flags list between FB 2.5 and 3.0 is easy - how to translate those to Provider's options I don't know – Arioch 'The Nov 05 '19 at 08:36
  • `ibase.h` of FB 2.5.9 ends with `#define isc_spb_trusted_role 113` and FB 3RC2 adds there `#define isc_spb_process_name 112 / #define isc_spb_trusted_role 113 / isc_spb_verbint 114 / isc_spb_auth_block 115 / isc_spb_auth_plugin_name 116 / #define isc_spb_auth_plugin_list 117 / isc_spb_utf8_filename 118 / isc_spb_client_version 119 / isc_spb_remote_protocol 120 / isc_spb_host_name 121 / isc_spb_os_user 122 / isc_spb_config 123 / isc_spb_expected_db 124` - but I don't know if it will help you much – Arioch 'The Nov 05 '19 at 08:42
  • @Arioch'The Thanks for the answer - but do you have any idea of a .NET forum which will be good to ask in? – Michael Eriksen Nov 05 '19 at 18:57
  • @MichaelEriksen You can go here: https://groups.google.com/forum/#!forum/firebird-net-provider – Mark Rotteveel Nov 06 '19 at 06:42
  • @MichaelEriksen You could also consider asking a **new** question with all relevant details here on Stack Overflow. As a datapoint, using Firebird 2.5.9 and FirebirdSql.Data.FirebirdClient 7.1.1 I'm able to run a backup just fine. – Mark Rotteveel Nov 06 '19 at 16:44
0

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.

Michael Eriksen
  • 167
  • 1
  • 3
  • 13