 |
|
 |
Tutorial - Get it working with 64 bit Winform
REF:
Brief tutorial: http://www.codeproject.com/Articles/9445/Embedded-Firebird-Full-Featured-Embedded-Database
Embedded Firebird: http://www.firebirdsql.org/en/firebird-2-5-1/#Win64
Firebird provider src: http://www.firebirdsql.org/en/net-provider/
Firebird doc: http://www.firebirdsql.org/en/documentation/
Firebird Language reference: http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25.html
Firebird DataType (Compare to M$SQL): http://www.firebirdsql.org/manual/migration-mssql-data-types.html
Firebird Language Reference - CREATE TABLE: http://www.firebirdsql.org/refdocs/langrefupd15-create-table.html
STEP 1. Download Firebird embedded dll's - in this example, "Firebird-2.5.1.26351-0_x64_embed" from \Download\Firebird 2.5\Win64\64-bit Embedded
http://www.firebirdsql.org/en/firebird-2-5-1/#Win64
Extract the package. You'd later need to copy "fbembed.dll" and other dll's into your application root directory.
STEP 2. Download .NET Provider
In this example, NETProvider-2.7.5-src. Extract the package and compile with [target=x64] from Visual Studio
http://www.firebirdsql.org/en/net-provider/
Your "Provider" can be found here:
...\ClientProviderSrc\source\FirebirdSql\Data\bin\Debug\FirebirdSql.Data.FirebirdClient.dll
STEP 3. Create a dummy .NET Winform project,
STEP 3.1 add reference to your Firebird provider:
...\ClientProviderSrc\source\FirebirdSql\Data\bin\Debug\FirebirdSql.Data.FirebirdClient.dll
Also, put all dll's from Firebird-2.5.1.26351-0_x64_embed package (STEP 1) under application root.
STEP 3.2 From Form1.cs,
using FirebirdSql.Data.FirebirdClient;
STEP 3.3 Add a button, try out basic moves ...
string connectionString = "ServerType=1;User=SYSDBA;Password=masterkey;Dialect=3;Database=";
// REF: http://www.codeproject.com/Articles/9445/Embedded-Firebird-Full-Featured-Embedded-Database?msg=4252054#xx4252054xx
private void button1_Click(object sender, System.EventArgs e)
{
string DbFilePath = @"C:\...\EmbeddedDB\Firebird\Sample\EmbeddedFirebirdExample\bin\x64\Debug\TestingDatabase.FDB";
string FullConnString = this.connectionString + DbFilePath;
// STEP 1. Create (or Re-create) database and database file
if (!System.IO.File.Exists(DbFilePath))
{
FbConnection.CreateDatabase(FullConnString);
}
FbConnection conn = new FbConnection(FullConnString);
conn.Open();
// STEP 2. Change default SYSDBA pwd? No!
// This will not work on embedded Firebird!
/*
string AlterPwdCmdSQL = "alter user SYSDBA password 'xyzabc123'";
FbCommand AlterPwdCmd = conn.CreateCommand();
AlterPwdCmd.CommandText = AlterPwdCmdSQL;
AlterPwdCmd.ExecuteNonQuery();
*/
// STEP 3. Create a table
// NOTE: Can only do this once!
// REF 1: http://web.firebirdsql.org/dotnetfirebird/blog/2005/01/creating-database-programmatically.html
// REF 2: http://www.firebirdfaq.org/faq69/
// STEP 3.1 Check if table exists - CAUTION: Table name upper case!!!
string SimpleCheckIfTableExists = "select count(1) from rdb$relations where rdb$relation_name = 'EIK'";
FbCommand CheckTableExistCmd = conn.CreateCommand();
CheckTableExistCmd.CommandText = SimpleCheckIfTableExists;
int CountTable = (int)CheckTableExistCmd.ExecuteScalar();
if (CountTable > 0)
{
// Drop table
string SimpleDropTableIfExists = "drop table EIK;";
FbCommand DropTableCmd = conn.CreateCommand();
DropTableCmd.CommandText = SimpleDropTableIfExists;
DropTableCmd.ExecuteNonQuery();
}
// STEP 3.2 Re-create the table
// CAUTION:
// (a) "Timestamp" is a reserved keyword for Firebird.
// (b) Table name "eik" -- Actual created table name = "EIK"
string SimpleCreateTableSQL = "create table eik (a int not null primary key, b int not null unique, c timestamp default current_timestamp);";
FbCommand CreateTableCmd = conn.CreateCommand();
CreateTableCmd.CommandText = SimpleCreateTableSQL;
CreateTableCmd.ExecuteNonQuery();
// STEP 4. Insert row
// NOTE: Can only do this once! (PK constraint!)
string SimpleInsertSQL = "insert into eik (a,b) values (123,456);";
FbCommand InsertRowCmd = conn.CreateCommand();
InsertRowCmd.CommandText = SimpleInsertSQL;
InsertRowCmd.ExecuteNonQuery();
// STEP 5. A simple select
FbDataAdapter da = new FbDataAdapter("SELECT * FROM eik", FullConnString);
// FbDataAdapter da = new FbDataAdapter("SELECT * FROM table1", this.connectionString + this.textBox1.Text);
DataTable dt = new DataTable();
da.Fill(dt);
this.dataGrid1.DataSource = dt;
}
STEP 4. Bulk Insert?
With SQL Server,
DataRow[] RowsImported = LoadFromSomeDataTable(MyData);
bc = new System.Data.SqlClient.SqlBulkCopy(Conn);
bc.BulkCopyTimeout = 60 * 60;
bc.DestinationTableName = SomeName;
bc.WriteToServer(RowsImported);
With Firebird, you have to make do with external table, quoting - http://www.firebirdfaq.org/faq209/
CREATE TABLE ext1 EXTERNAL 'c:\myfile.txt'
(
field1 char(20),
field2 smallint
);
To do quick import into regular table, do something like this:
INSERT INTO realtable1 (field1, field2)
SELECT field1, field2 FROM ext1;
This insert would still check constraints, foreign keys, fire triggers and build indexes. If you can, it is wise to deactivate indexes and triggers while loading and activate them when done.
STEP 5. You can't change SYSDBA pwd for embedded Firebird - in fact there's no need to do so. The following won't work!
string DbFilePath = @"D:\...\SampleData.FDB";
string FullConnString = this.connectionString + DbFilePath;
FbConnection conn = new FbConnection(FullConnString);
conn.Open();
string AlterPwdCmdSQL = "alter user SYSDBA password 'xyzabc123'";
FbCommand AlterPwdCmd = conn.CreateCommand();
AlterPwdCmd.CommandText = AlterPwdCmdSQL;
AlterPwdCmd.ExecuteNonQuery();
Upon ExecuteNonQuery -
+ ex {"unsuccessful metadata update\r\nI/O error during \"CreateFile (open)\" operation for file \"C:\\...\\EMBEDDEDFIREBIRDEXAMPLE\\BIN\\X64\\DEBUG\\SECURITY2.FDB\"\r\nError while trying to open file"} FirebirdSql.Data.Common.IscException
Seems like I'm not the first person running into this problem:
http://tech.groups.yahoo.com/group/firebird-support/message/83729
Now, quoting here http://www.firebirdsql.org/manual/ufb-cs-embedded.html
The Windows Embedded Server is a Superserver engine plus client rolled into one library, called fbembed.dll. It is available as a separate download package. The embedded server (introduced with Firebird 1.5) was specifically designed to facilitate deployment of applications that ship with a Firebird server included. Installation is just a matter of unpacking the DLL and a few other files to the desired location. The security database is not used at all: anyone can connect to any database, as long as the user running the application has filesystem-level access rights to the database(s) in question... The embedded server has no facility to accept any network connections. Only true local access is possible, with a connect string that doesn't contain a host name (not even localhost).
So, there's nothing you can do to secure an embedded Firebird - you can only secure the Windows machine/OS on which the Firebird db resides.
STEP 6. DbProviderFactories.GetFactory will fail unless you reference the dll from app.config!
DbProviderFactories.GetFactory("FirebirdSql.Data.FirebirdClient"); <-- This will blow up!
To do this,
STEP 6.1 - determine public key token
D:\...\Firebird\ClientProviderSrc\source\FirebirdSql\Data\bin\Debug>gacutil /i FirebirdSql.Data.FirebirdClient.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly successfully added to the cache
Now, /u will tell you public key of the dll!
D:\...Firebird\ClientProviderSrc\source\FirebirdSql\Data\bin\Debug>gacutil /u FirebirdSql.Data.FirebirdClient
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
D:\...\Firebird\ClientProviderSrc\source\FirebirdSql\Data\bin\x64\Debug>gacutil /u FirebirdSql.Data.FirebirdClient
Assembly: FirebirdSql.Data.FirebirdClient, Version=2.7.5.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=AMD64
Uninstalled: FirebirdSql.Data.FirebirdClient, Version=2.7.5.0, Culture=neutral,
PublicKeyToken=3750abcc3150b00c, processorArchitecture=AMD64
Number of assemblies uninstalled = 1
Number of failures = 0
STEP 6.2
... other stuff ...
<!-- rao: Firebird driver; prefer locally placed driver (any version)-->
... other stuff ...
REF: http://programming.2be-it.com/?p=160
dev
modified 16 May '12.
|
|
|
|
 |
|
|
 |
|
 |
hi,
error:
Could not load file or assembly 'System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
scenario:
used embedded firebird ado.net service provider for databse conectivity.
no issues with firebird's dll coz able to use classes such as FbDataAdapter,FbConnection,FbCommand but when tries to read with FbDataReader or fill dataset with FbDataAdapter it gives this error
i tried using excel database n it works fine...
i hav downloaded firebird installed then added refrance n copied fbembed.dll in \bin\Debug following your tutorial on this site n then jus used namespace FirebirdSql.Data.FirebirdClient; so after that i m able to acces FbDataAdapter etc;
this procedure is fine or somthng missin???
|
|
|
|
 |
|
 |
Hello
I´m developing an application using Firebird Embedded, and I would like to know how I can maintain the connection open, in other words, I would like through a Module to open the connection with the database and then close when the application stop.
Oww sorry, I´m using VB.NET 2008.
Thnks
Rafael Brasil
|
|
|
|
 |
|
 |
I've been planing to implement this in to a small program that I'm writing (which I may release on CodeProject) but it appears that Embedded Firebird is not longer supported.
I found this:
http://www.firebirdsql.org/dotnetfirebird/index.html[^] which is different from the link given to the article.
In short, the project was donated to the Core Firebird project. I thought that this was great, it might mean tighter integration.
However after some more sifting around, it appears that the project has never been updated.
To the best of my ability I've been able to determine this embedded package supports Firebird 2.0.1 on .NET 2.0. But I was hoping to use Firebird 2.1 on .NET 3.5.
But quite simply does anyone know one way or another if this project is still supported?
Thank you,
Frank
|
|
|
|
 |
|
|
 |
|
 |
Ahh, I see. I was looking at the wrong pages. How confusing.
Anyway, I actually decided to go with SQLite for my project. Same concept but so far support has been better for it. Plus, I'm too deep in now to switch back.
Thank you for your reply and the information!
Regards,
Frank
|
|
|
|
 |
|
 |
this is not working for firebird 2 might be because of version of dlls,
any idea???
ujjwal
|
|
|
|
 |
|
 |
Hi, i switched from Super Server 2.0 to embedded version.
Everything almost ok, select, inserts, deletes work fine. However, stored procedures won't work at all, which of course worked well on the SuperServer.
Is this normal? Is there something to change on those procedures in order to get them working?
Thanks for your time folks.
Daniel Sovino
|
|
|
|
 |
|
 |
How can I change .fdb files?
|
|
|
|
 |
|
 |
.fdb stands for firebird database.
You "change" it by using firebirdsql to access it, sending mysql commands to edit,add to, and remove from it.
|
|
|
|
 |
|
 |
Please, help!
When compile example sources myself, at runtime exception occured
"Unable to load DLL 'fbembed'"
I put fbembed.dll in bin/Debug path, but still not work((
|
|
|
|
 |
|
 |
jet85 wrote: When compile example sources myself, at runtime exception occured
"Unable to load DLL 'fbembed'"
I put fbembed.dll in bin/Debug path, but still not work((
I am having the same problem. I am working with C#, .NET 2.0. The Firebird DB is version 2. I can connect to the embedded database with IBExpert. I have the embedded engine and Firebird client installed and a reference to it added to my project. Is there something else I'm missing?
Thanks!
TC
|
|
|
|
 |
|
 |
I solved this problem.
Files icudt30.dll, icuin30.dll, icuuc30.dll must also putted in work directory.
I think it relevant only for Firebird version 2.
What is mission of these files? And how to use fb without them?
|
|
|
|
 |
|
 |
I forgot I had posted this question. I figured it out yesterday morning and got my connection to open! Now I just need to figure out how to add the Firebird db to my data sources in VS 2005...
TC
|
|
|
|
 |
|
 |
In some cases this still is not enough. For example on a win2003 server it's impossible to get such an application run. I've trying now to include also the irectory Intl from the FBEmbed setup...
Also someone said that putting the above mentioned DLLs (fbemned, icuuc30, etc.) to the windows\system32 will solve the problem, but didnt
C#, ASPX, SQL, novice to NHibernate
|
|
|
|
 |
|
 |
dude u rock!, solved my daily headacke...
|
|
|
|
 |
|
 |
From the Firebird FAQ[^] it seems that Firebird uses a DLL called Fbembed.dll that is not managed. That is, embedding Firebird is unsafe in the C# / common language infrastructure sense of "unsafe". This means that an application that embeds Firebird cannot be installed in scenarios that require safe (trusted) applications. I wanted to point this out in case anyone else, like me, was searching for a safe embeddable SQL database setup.
SQLite with System.Data.SQLite seems to have the same characteristics.
The search continues..
By the way, does the term "embedded database" used in this article have a standard meaning? There is no Wikipedia entry for it.
|
|
|
|
 |
|
 |
Is it possible to change the password (masterkey) for the embedded?
|
|
|
|
 |
|
 |
Since the password for the Firebird database is not stored in the db there is no
point of doing that. If someone copies your db she/he will be able to open it with
the default sysdba/masterkey. The user/password has a meaning and point when remote
users are connecting to a Firebird server (when you can't get physical access to the db).
I think this is how it works on Fb.
|
|
|
|
 |
|
 |
Do you have any suggestions for database protection?
So nobody can easily open the firebird database file.
Thanks,
|
|
|
|
 |
|
 |
Firebird Defaults: User = "SYSDBA" Pass = "masterkey"
You can add new users or change password sysadmin user in
+ With Firebird 1.x: security.fdb
+ With Firebird 2.x: secutity2.fdb
You can find them in Firebird Folder.
Best regards
|
|
|
|
 |
|
 |
HUm... I was trying to
string DbFilePath = @"D:\...\SampleData.FDB";
string FullConnString = this.connectionString + DbFilePath;
// FbConnection.CreateDatabase(FullConnString);
FbConnection conn = new FbConnection(FullConnString);
conn.Open();
string AlterPwdCmdSQL = "alter user SYSDBA password 'xyzabc123'";
FbCommand AlterPwdCmd = conn.CreateCommand();
AlterPwdCmd.CommandText = AlterPwdCmdSQL;
AlterPwdCmd.ExecuteNonQuery();
Upon ExecuteNonQuery -
+ ex {"unsuccessful metadata update\r\nI/O error during \"CreateFile (open)\" operation for file \"C:\\...\\EMBEDDEDFIREBIRDEXAMPLE\\BIN\\X64\\DEBUG\\SECURITY2.FDB\"\r\nError while trying to open file"} FirebirdSql.Data.Common.IscException
I'm not sure how to ALTER USER and change SYSDBA pwd programmatically... (For Embedded Firebird, not standalone server), Anyone any clue?
Seems like I'm not the first person running into this problem:
http://tech.groups.yahoo.com/group/firebird-support/message/83729[^]
Now, quoting here[^]
The Windows Embedded Server is a Superserver engine plus client rolled into one library, called fbembed.dll. It is available as a separate download package. The embedded server (introduced with Firebird 1.5) was specifically designed to facilitate deployment of applications that ship with a Firebird server included. Installation is just a matter of unpacking the DLL and a few other files to the desired location. The security database is not used at all: anyone can connect to any database, as long as the user running the application has filesystem-level access rights to the database(s) in question... The embedded server has no facility to accept any network connections. Only true local access is possible, with a connect string that doesn't contain a host name (not even localhost).
Sounds like there's nothing you can do to secure an embedded Firebird - you can only secure the Windows machine/OS on which the Firebird db resides.
REF: Firebird Quickstart Guide (Scroll to page 16)[^]
dev
modified 15 May '12.
|
|
|
|
 |
|
 |
Hi;
I need some help connecting to a regular 1.5 Firebird database using VB.Net. Here's a sample of what I have and the error I'm getting. (I should point that I'm totally new to VB.Net)
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myConnection As FbConnection
Dim myCommand As FbCommand
.....
The errors tell me that the FbConnection and FbCommand are undefined types. I have FirebirdClient-2.0 installed. I'm obviously leaving out whatever defines FbConnection and FbCommand, however I have know idea what I'm missing and could use a bit of assistance.
Thanks
|
|
|
|
 |
|
|
 |