Working with FireBird and InterBase databases from C#
Often I need to interact with various applications written in .NET with FireBird and InterBase databases. Therefore, I decided to write an example for memory, so that next time I don't have to search through my own sources, but quickly look here. Maybe someone else will also find it useful.
To connect to the database, we will need a Connector: «FirebirdClient-2.5.0-Alpha2.msi» — in my case, such, possibly already newer. (search in the search engine — you'll find it).
After installation in Program Files a folder FirebirdClient 2.0 will appear — in it, the necessary libraries are located. Add from there to our project through «Add Reference» the library: FirebirdSql.Data.FirebirdClient.dll
Further, there are no differences from working with any other databases in .NET, example:
//Подключение к FireBir.
string connectionString = "User=SYSDBA;Password=masterkey;Database=D:\\SMDK\\DBase\\SmarketFood.fdb;DataSource=roman-book;Port=3050;Dialect=3;Charset=WIN1251;Role=;Connection lifetime=30;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0;";
FbConnection con = new FbConnection(connectionString);
//Думаю строка подключения хотя и большая но понятная
And then, as usual, the standard set of Methods:
con.Open();
FbCommand command = new FbCommand("select count(*) from table", con);
con.Close();
//FbDataReader - DataReader. (Всё как обычно работает аналогично)
//FbDataAdapter - DataAdapter. (Точно так-же)
P.S.
FirebirdClient-2.5.0-Alpha2.msi — I checked, works perfectly with FireBird and InterBase.
Comments (0)
No comments yet.