Profile photo of Anton

by

Accessing Firebird Embedded databases from Data Abstract for .NET

January 11, 2012 in .NET, Data Abstract

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.

Note:
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.

Setup

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-2.5.1.26351-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):


Connection Wizard
If you now press the ‘Test Connection’ button, this test will fail (if it doesn’t fail, it means you still have the Firebird server running):


Connection Test failed
And now the most important part begins:
Add the following text to the custom driver-dependent parameters:

ServerType=1


Connection Wizard
Now press the ‘Test Connection’ button again. If you forgot to copy some files, you’ll see something like this:


Connection Test failed (due to missing DLL)
But if everything was done right, you’ll see the much more pleasant message:


Connection Test succeeded
So the first part is done. We have deployed the needed files and successfully tested the Firebird Embedded connection.

Sample Server

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:


Connection Wizard
You need to correct the path to the PCTrade.FDB database and add ‘ServerType=1′ to the connection’s custom properties.

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.


JavaScript Data Client


Sample Server

Note that Data Abstract for JavaScript was used to create the client app in pure HTML + JS.

x64 OS support

The Sample Server will crash if you use the x64 OS edition:


x64 Failure

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:


VS Project Properties pane

Conclusion

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.

Comments are closed.