2

I have COMPUTER_WITH_DATABASE where is superserver firebird (windows) installed. Now i need to make c# application which will connect to this COMPUTER_WITH_DATABASE and create file .fdb like for example database.fdb to be later able to connect from other computers using for example part of string like:

COMPUTER_WITH_DATABASE\c:\database.fdb

But how to do it using fb API in c#?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
user1654591
  • 85
  • 2
  • 6
  • [How to create an embedded database using Firebird in C#](http://stackoverflow.com/questions/8725546/how-to-create-an-embedded-database-using-firebird-in-c-sharp) – Sen Jacob May 03 '13 at 08:41
  • 1
    [Creating Firebird database programatically (C#/.NET)](http://blog.cincura.net/7968-creating-firebird-database-programatically-c-net/) – Sen Jacob May 03 '13 at 08:42

1 Answers1

8

with this code you can create a database:

...
using FirebirdSql.Data.Firebird;
...

FbConnectionStringBuilder builder = new FbConnectionStringBuilder();
builder.DataSource = "COMPUTER_WITH_DATABASE";
builder.UserID = "SYSDBA";
builder.Password = "m*******y";
builder.Database = @"c:\database.fdb";
builder.ServerType = FbServerType.Default;

FbConnection.CreateDatabase(builder.ConnectionString);
jadelgado
  • 96
  • 3
  • `FbConnection.CreateDatabase` wants string (basically), not a `Hashtable`, hence this code is not completely correct. – cincura.net Jul 03 '14 at 10:05
  • Thank you, FbConnectionStringBuilder is best to use to create the connection string. – jadelgado Oct 29 '14 at 21:04
  • What if the database already exists. Does 'Create Database' deletes the old one? – TomeeNS Dec 10 '15 at 02:09
  • you can just code >>>>>>>> string curFile = @"c:\database.fdb"; if (File.Exists(curFile) == true) { MessageBox.Show("Database is already existing!"); }<<<<<<<<<<< to detect if database is already available hope this help – Mandz Apr 24 '18 at 05:56