Icarsel
Icarsel

Reputation: 13

FirebirdSQL getting list of databases in C#?

I need to get the list of databases from a Firebird server in a computer. I want to select and backup whichever database I want. Microsoft SQL Server has that feature, I think you can see the databases connect a server. Is there such thing in Firebird? Or is there a workaround? I am working with Firebird 2.5, but if there is a version it is possible you can let me know.

Upvotes: 1

Views: 1164

Answers (2)

Ed Mendez
Ed Mendez

Reputation: 1683

Although Firebird does not keep track of databases like SQL Server, you might be able to accomplish what you want some other way. You said you want to pick and choose the database to backup. Do you have an off the shelve application to perform the backup, or will you develop one? Another question is if your databases are somewhat static, or do the databases on a particular server stay somewhat the same?

If the list of databases stays somewhat static and you will be developing a UI to perform/submit the database backup, I would do something like the following.

Create a database that will contain a table containing connection strings of the databases that you want backed up. Granted the table will need to be amended when you add/remove databases. Develop your UI to look to this table to pick the database to backup.

I've done something similar in the past. In my case it was poor-mans schema backup. I had a database contain and table of the relevant database connection strings, and I wrote an app that would iterate over that table list and connect to those databases and then perform metadata extracts, and then parse out the metadata extracts into individual objects and then pull in the individual objects into another database to store the schema.

Upvotes: 0

Mark Rotteveel
Mark Rotteveel

Reputation: 108971

Firebird has no feature to list databases, because technically Firebird doesn't know which databases exist on a server (except those defined in aliases.conf/databases.conf, but those aren't exposed either).

For Firebird, a database is defined entirely by a database file that is either referenced by a full file path or an alias (which points to a file path). If the file exists, the Firebird process has sufficient access rights to the file, and the file has an On-Disk Structure (ODS) the server understands, you can connect to it.

This is different from SQL Server, where the server holds a list of databases, and you can only connect to databases defined in that list.

Upvotes: 1

Related Questions