Accessing Firebird Embedded databases from Data Abstract for .NET
Recently, we already tried to work with the SQL Server 2012 LocalDB database. Now let’s try a more old-fashioned database, like Firebird Embedded. Again, we’ll modify the Sample Server application shipped with Data Abstract for .NET.
Let’s start with the FB Embedded installation.
In this article, I’ll use the PCTrade Firebird database, restored from the backup file
c:\Users\Public\Documents\RemObjects Samples\Data Abstract for .NET\Server\Scripts\PCTrade_FB.fbk
shipped with the Data Abstract for .NET samples.
Actually, there is no installation needed at all for FB Embedded. All you need is to download a file from http://sourceforge.net/projects/firebird/files/ (you’ll need to choose your platform and to download the file Firebird-…_Win32_embed_….zip). For example, the file containing Firebird 2.5.1 Embedded for Win 32 is named http://sourceforge.net/projects/firebird/files/firebird-win32/2.5.1-Release/Firebird-18.104.22.168351-0_Win32_embed.zip
This archive contains more than 2 dozen files, but we need only four of them at this moment – fbembed.dll, icudt30.dll, icuin30.dll and icuuc30.dll (don’t forget to check the README_embedded.txt file for more details on installation and files needed).
You need to copy this file next to the Schema Modeler’s .exe file to allow Schema Modeler to load the Firebird Embedded engine at runtime when needed.
Now let’s check if everything is done right.
Shut down the Firebird server if you have one running. Start the Schema Modeler and create a new connection (don’t forget to set the correct path to PCTrade.FDB):
Add the following text to the custom driver-dependent parameters:
Now let’s modify a real application.
Open the “c:\Users\Public\Documents\RemObjects Samples\Data Abstract for .NET\Server\DASampleServer.Wpf.2010.sln” solution. Add the files fbembed.dll, icudt30.dll, icuin30.dll and icuuc30.dll via the ‘Add Existing Item’ dialog to the DASampleServer.Engine.2010 project. Double-check that all 4 newly added files have their Build Action property set to Content and their Copy to Output Directory property set to Copy Always.
Double-click the DASampleService.daSchema file and edit the PCTrade.FB connection:
Now build and run the server.
Select the PCTrade.FB connection and… That’s it! The data was successfully retrieved from the FB Embedded database.
x64 OS support
The Sample Server will crash if you use the x64 OS edition:
This happens because of an attempt to load x86 Firebird Embedded libraries into a .NET application build with the ‘Any CPU’ target platform. Such applications run in x64 mode on x64 OS and thus cannot load x86 libraries. The solution is either to provide x64 libraries or to set the x86 target platform in project’s properties:
This article shows how to use Data Abstract for .NET and Firebird Embedded together (and that it’s no effort at all to do this). All you need is to deploy the needed dll’s and to remember about the x86/x64 compatibility caveat.