Saturday, May 2, 2009

Create a new embedded Firebird database

This post will show you how to create a new database file with the embedded Firebird from a C# .NET application.

Using ADO.NET Provider earlier than 1.7

For the ADO.NET Provider 1.6 it was necessary to specify username and password (it makes no sense for the embedded Firebird anyway).

C# .NET

Hashtable parameters = new Hashtable();

parameters.Add("User", "SYSDBA");

parameters.Add("Password", "masterkey");

parameters.Add("Database", "MyDatabase.fdb");

parameters.Add("ServerType", "1");

FbConnection.CreateDatabase(parameters);

Using ADO.NET Provider 1.7

The method FbConnection.CreateDatabase(Hashtable) is now obsolete. All you need now is just the connection string (the username and password are no longer needed).

C# .NET

FbConnection.CreateDatabase(@"Database=MyDatabase.fdb;ServerType=1");



kick it on DotNetKicks.com

1 comment:

Anonymous said...

Try EffiProz Database http://www.EffiProz.com,
EffiProz is a database written entirely in C#. comprehensive SQL support including Stored Procedures, Triggers and Functions. Ideal for embed in .Net applications. Support Silverlight 3 and .Net compact framework as well
Include Visual Studio ad-in, ADO.Net provider, Entity Framework provider, etc.