28
Jan

Firebird Embedded and .NET

Firebird Embedded is a very popular, special, version of Firebird database engine. The main advantage is, that there’s no need to install it. Not to bring some wrong information, it’s not some crippled down version (there are some limitations, but it’s the being embedded consequence) – it’s the fully-featured database engine. For those, who don’t know what Firebird is or just want to discover what this – more than twenty years audited – engine is able to do, can study this document – it will not take more than two minutes.

Let’s get back to the FB Embedded and .NET. So, what we’ll need? Of course, the Firebird. You can download it from http://www.firebirdsql.org/ pages, current version 2.0 particular from http://prdownloads.sourceforge.net/firebird/Firebird-2.0.0.12748-0_embed_win32.zip. The second stuff we’ll download is Firebird ADO.NET Data Provider. It’s available for .NET Framework 1.1, 2.0, Compact Framework 2.0, Mono 1.1.18+. DDEX Provider for Visual Studio 2005 is available too. Download version that fits your needs from http://www.firebirdsql.org/index.php?op=files&id=netprovider. Cause‘ we want not to do any installations on machines (except the developer’s machine) we will use only necessary files:

Except these necessary files is there a couple of files, that are not absolutely required, but it’s good to add it into pack:

Note: On some systems or configurations aren’t available libraries msvcp71.dll and msvcr71.dll. These you’ll find in downloaded package too and if required distribute it together with application.

Creating an application is then a minute. Just add into references FirebirdSql.Data.FirebirdClient assembly and add near to program fbembedd.dll (or generally into place, where system tries to load DLLs by default). Some example of “well-configured” Firebird you can find here (note: files are after build copied into bin directory on top level, so from this location you have to run it).

As I said on beginning, Embedded Firebird has some limitations, and it’s good to know about these during choosing database platform. First is the necessity to connect to database only thought local protocol, so the TCP/IP connection using “localhost” or “127.0.0.1″ will not work. The next is, that Firebird isn’t doing any checking during connecting (and it would not make sense, because client and server are in same address space). Permissions to database object are applied of course. The last limit is fact, that embedded version isn’t good (but can work) for ASP.NET environment, cause’ the file is exclusively locked during first connection by this application.
On other side, very positive is difficulty of moving into “normal” Firebird server. You’ll just modify connection string and everything else will work in same way – no other changes, no code changes. You can scale your application from one user up to thousands without any additional effort.

Today we showed how easy can be using Firebird in embedded environment, with keeping full SQL and ACID functionality.


Czech version originally created for vyvojar.cz.

 

There's 14 Comments So Far

  • Emil Mustea
    February 4th, 2007 at 20:13

    You are wrong. You can use Firebird Embedded for ASP.NET as long the connections come from a single process. So in connection pool you can specify a number of connections which Firebird Embedded will accept but will not accept connections from another process (another connection pool)

  • Frantisek U.
    February 4th, 2007 at 20:52

    Na zaklade Vasi ‘propagace’ jsem se rozhodl FB vyzkouset, ale potykam se s tim, ze neexistuje dost materialu jak FB pouzivat v .NET.Existuje nekde prosim priklad, jak vytvorit ulozenou proceduru, ktera ma vraci seznam dat na zaklade predanych parametru a jak takovouto proceduru pak pouzit v C#?Mam totoiz problem s tim, ze kdyz SP vraci radky, tak se musi volat pres “SELECT * FROM SP” misto zaziteho EXEC a ja nevim, jak ty parametry predat do FbCommand.Parameters (jde mi prirozene o zabraneni SQL Injection)Dekuji.BTW: V ASP.NET aplikacich embedded FB pouzivat lze, ale jen v ramci jednoho procesu.

  • cincura.net
    February 4th, 2007 at 22:03

    > Na zaklade Vasi ‘propagace’ jsem se rozhodl FB vyzkouset, ale potykam> se s tim, ze neexistuje dost materialu jak FB pouzivat v .NET.Ano, materialu neni dost. Nicmene zrovna v .NETu se pouziti DB jako takove mc nelisi od obecne DB. Spis je problem pochopit nektere syntakticke veci FB a take nektere architektonicke. > Existuje nekde prosim priklad, jak vytvorit ulozenou proceduru, ktera> ma vraci seznam dat na zaklade predanych parametru a jak takovouto> proceduru pak pouzit v C#?Proceduru vytvorite naprosto stejne jako v isql, …, zde na to nema C# nebo jine prostredi vliv. > Mam totoiz problem s tim, ze kdyz SP vraci radky, tak se musi volat> pres “SELECT * FROM SP” misto zaziteho EXEC a ja nevim, jak ty> parametry predat do FbCommand.Parameters (jde mi prirozene o> zabraneni SQL Injection)Jsou dve moznosti. Bud pouzijete zmineny select a normalne @param1, @param2, … a parametry naplnite. Naprosto standardni postup pro select.A nebo volate primo proceduru, tr.:FbConnection conn = new FbConnection(connectionString); FbCommand cmd = new FbCommand(“procedura”, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(“@param1″, FbDbType.VarChar, 10).Value = param1; cmd.Parameters.Add(“@param2″, FbDbType.VarChar, 10).Value = param2; > Dekuji.> > BTW: V ASP.NET aplikacich embedded FB pouzivat lze, ale jen v ramci> jednoho procesu.Ano, prece jsem nepsal, ze to *neni* mozne. Jen ze jsou tam uvedene limitace.

  • cincura.net
    February 4th, 2007 at 22:53

    2Emil Mustea> Yes, I’m not writing that it’s *not* possible, but that there’re some limitations and IMHO using server is in this case better choice.

  • Firebird .NET Data Provider with crystal report
    March 22nd, 2007 at 17:34

    HiI have installed firebird .net data provide and create new connection at crystal report but no any list shown.. , it work properly at vs2005. How to set up for crystal report.

  • cincura.net
    March 22nd, 2007 at 21:07

    I’m not using CR at all, so I don’t know how it works. But I suppose, that if you’re able to use Server Explorer and these design-time features, the CR should work too.

  • turkey
    July 30th, 2008 at 19:17

    thanx docs

  • rüya tabiri
    November 25th, 2008 at 08:47

    thank you…

  • Ben
    December 5th, 2008 at 17:41

    Thanks so much, that was the information that I was missing on getting firebird to function in an embedded mode with .NET

  • chat
    January 3rd, 2009 at 20:41

    thank you

  • granit
    March 14th, 2009 at 19:30

    Thank You…

  • sikiş filmi
    June 1st, 2009 at 11:50

    THANKS EVER SO MUCH!!!

  • azgın kadınlar
    July 10th, 2009 at 15:31

    thanks most

Who Linked To This Post?

  1. Firebird News » Firebird Embedded and .NET

Share your thoughts, leave a comment!