Click here to Skip to main content
Click here to Skip to main content

Data Application Block for Firebird SQL

, 29 Mar 2006
Rate this:
Please Sign up or sign in to vote.
Data Application Block for Firebird SQL intended to speed the development of applications.

Sample Image - fb_burning_within2.gif

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 return 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 send 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.
// First we declare a a string
// and assign our connection string to it. 
// In a production system, you would be probably
// have this connection in a central repository 
// and have the DBObject get set it from within the class.
string myConnectionString = "User=SYSDBA;Password=masterkey;" + 
                            "Database=EMPLOYEE.FDB;ServerType = 1;"; 

// Instantiate the DBObject class
DBObject myDBObject = new DBObject(myConnectionString);

//Set parameter to the DBObject class. Note that to keep it simple 
//the store procedure in this case doesn’t take any parameters.
//There is an example with parameter s in the sample code for this article.
//Also, notice that I bind the dataset 
//the RunProcedure() method returns to a datagrid.
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

This article was first submitted to CodeProject on 03/29/2006.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Xela220
Web Developer
United States United States
Alex is the founder, President, Architect, of a one man development and consulting company (Avida, Corp of Miami, FL), and he is also a shameless self promoter. A deserter of the accounting profession, Alex is been developing/supporting windows and web applications for Fortune 500 and small companies as well since 2000.
 
His programming experience includes VB6, VB.NET, C#, ASP, ASP.NET, MSSQL 7/2000/2005, Firebird SQL 1.7. Alex has acquired expertise in Visual Studio, Reporting Services, SQL Server, and other stuff that I can’t remember right now.
 
In his spare time, he enjoys bicycling with his trusted Litespeed titanium racing bike which is his favorite material possession.
 
He goes anywhere and takes any challenge that the Technology field troughs at him, and sometimes he even wins. He can be more often found at code camps, user groups, the local Microsoft office’s cafeteria, or sleep in his couch.

Comments and Discussions

 
AnswerGreat job PinmemberKelly Cristina Mara8-Feb-08 11:34 
GeneralRe: Great job PinmemberDonsw21-Feb-09 4:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 29 Mar 2006
Article Copyright 2006 by Xela220
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid