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

FireBird SqlAssistant - A FireBird SQL Data Block

By , 16 Jan 2007
 

FireBird.SqlAssistant

FireBird.SqlAssistant

FireBird.SqlAssistant

FireBird.SqlAssistant

Introduction

In his article, Data Application Block for Firebird SQL, Alex provided a great library to start working with FireBird. I tried to imporve that library in some ways. You could also take a look at FireBird SqlHelper - A Data Access Application Block For FireBird to have a data access block similar to Microsoft Data Access Block V2.

Points of Interest

Following features could be of higher interest:
  • FireBird.SqlAssistant is completly stateless.
  • Small foot print FireBird.SqlAssistant.dll is 24kb.
  • Supports quick INSERT, UPDATE, DELETE, SELECT, SELECTALL methods.
  • Supports to place long SELECT queries in an INI file 'Query.ini'. This could be helpful in code maintainability in some projects.
  • Simplified stored procedure calling by reducing function signature of Alex's DataBlockFirebirdSQL.
  • Provides many handy helper functions like GetCount etc.

Using the Code

Following are few sample calls from Demo project available for download. You could simply add the reference of FireBird.SqlAssistant in your project and call SQLAssistant static functions.
private void Form1_Load(object sender, EventArgs e)
        {
            this.textBox1.Text = SQLAssistant.GetIniQuery("MyQuery1");
            this.textBox2.Text = SQLAssistant.GetIniQuery("MyQuery2");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.RefreshData();
        }

        private void RefreshData()
        {
            this.dataGridView1.DataSource = SQLAssistant.Execute("SELECT * FROM COUNTRY").Tables[0];
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string c = SQLAssistant.GetCount("COUNTRY").ToString();

            string v1 = "ACountry" + c;

            string v2 = "ACurr" + c;

            SQLAssistant.Insert("COUNTRY", "COUNTRY", v1, "CURRENCY", v2);

            this.RefreshData();

            MessageBox.Show("COUNTRY='" + v1 + "' added successfully");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            DataTable table = SQLAssistant.Select("COUNTRY", "COUNTRY", "USA").Tables[0];

            if (table == null || table.Rows.Count == 0)
            {
                MessageBox.Show("COUNTRY='USA' not found");

                return;
            }

            DataRow row = table.Rows[0];

            row["CURRENCY"] = "$";

            SQLAssistant.Update("COUNTRY", table.Rows[0], "COUNTRY", "USA");

            MessageBox.Show("CURRENCY='Dollar' is successfully updated to '$'");

            this.RefreshData();
        }


        private void button4_Click(object sender, EventArgs e)
        {
            SQLAssistant.Insert("COUNTRY", "COUNTRY", "TestCountry", "CURRENCY", "None");

            DataTable table = SQLAssistant.Select("COUNTRY", "COUNTRY", "TestCountry").Tables[0];

            if (table == null || table.Rows.Count == 0)
            {
                MessageBox.Show("COUNTRY='TestCountry' not found");

                return;
            }

            DataRow row = table.Rows[0];

            SQLAssistant.Delete("COUNTRY", row);

            MessageBox.Show("COUNTRY='TestCountry' is deleted successfully");

            this.RefreshData();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            this.dataGridView2.DataSource = SQLAssistant.ExecuteIni("MyQuery1").Tables[0];
        }

        private void button5_Click(object sender, EventArgs e)
        {
            this.dataGridView2.DataSource = SQLAssistant.ExecuteIni("MyQuery2").Tables[0];
        }

        private void button7_Click(object sender, EventArgs e)
        {
            this.dataGridView3.DataSource = SQLAssistant.ExecuteDataSet("ORG_CHART ", null).Tables[0];
        }

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Rafey
Web Developer
Pakistan Pakistan
Member
Software engineer developing solutions using Microsoft technologies.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralA small confusion [modified]memberGzzz3 May '07 - 22:14 
I'm just confused about the difference between the two data access classes mentioned in your articles titled "FireBird SqlHelper" and "FireBird SqlAssistant". I haven't yet looked at the code for the two yet and maybe i'll figure out the difference when I go through the code, but I'd appreciate if you could clear the difference of features between the two and also your preference for one out of the two.
 
Thanks alot.

Generalpicturesmemberdedel18 Jan '07 - 8:06 
I miss the last 3 pictures
GeneralRe: pictures [modified]memberRafey18 Jan '07 - 20:42 
Hi, all 3 pictures links refreshed.
 

-- modified at 2:50 Friday 19th January, 2007
 
Smile you will look better Smile | :)

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 16 Jan 2007
Article Copyright 2007 by Rafey
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid