Introduction
The Firebird SQL data application block is intended to speed up development, and it should be used in conjunction with data layer classes in much the same way as Microsoft’s data block. The sample included with this article uses the embedded Firebird SQL database (included in the sample) to demonstrate the use of the application block without having to bother setting up a database.
Background
Firebird SQL data application block was inspired by the Microsoft Application Blocks. The block provides overloaded methods to query a Firebird database which returns a DataSet
, DataTable
, or an integer in the case of scalar database calls. An additional overload method takes an existing DataSet
as a parameter and fills the results of a stored procedure sent as the parameter as well.
Using the Code
The block has one class called DBObject
. The main class has four main overloaded methods to do the work. The methods need to be accessed after the class has been instantiated passing the connection string to its constructor. The following is a list of the overrun procedures and their purpose:
- Overload
RunProcedure()
- Returns an integer indicating the return value of the stored procedure, and also returns the value of the RowsAffected
aspect of the stored procedure that is returned by the ExecuteNonQuery
method. - Overload
RunProcedure()
- Returns a FbDataReader
containing the result of the stored procedure. - Overload
RunProcedure()
- Creates a DataSet
by running the stored procedure and placing the results of the query/proc into the given table name. - Overload
RunProcedure()
- Takes an existing DataSet
and fills the given table name with the results of the stored procedure.
string myConnectionString = "User=SYSDBA;Password=masterkey;" +
"Database=EMPLOYEE.FDB;ServerType = 1;";
DBObject myDBObject = new DBObject(myConnectionString);
dataGridView1.DataSource =
myDBObject.RunProcedure("ORG_CHART ",
new IDataParameter[] { }, "tblMyDataTable");
dataGridView1.AutoGenerateColumns = true;
this.dataGridView1.DataMember = "tblMyDataTable";
Points of Interest
Well, I hope that you find this code useful. I have used the data block in conjunction with the embedded version of Firebird SQL for many of my stand-alone applications. I especially like the fact that the applications work out of the box without the need for additional installations. It makes deployment a breeze since the database is included in the application itself, and all it takes is a couple of DLLs with a very small footprint.
History
- 03/29/2006: First submitted to CodeProject