user575219
user575219

Reputation: 2440

Sqlite database utilites class

I am using SQlite as a database in a C# winforms application.

My project involves some select simple queries, inserts, deletes.

Currently, I have written all these sql, Ado.net queries in the codebehind.

For eg:

   private void frmPlant_Load(object sender, EventArgs e)
    {
        FillData();
    }
    void FillData()
    {
        dataGridView1.AutoGenerateColumns = true;
        string query = @"SELECT * FROM  [Table1]";

        using (SQLiteConnection conn = new SQLiteConnection(connString))
        {
            conn.Open();
            da = new SQLiteDataAdapter(query, conn);
            ds = new DataSet();
            da.Fill(ds, "T1");
            dt = ds.Tables[0];
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = "T1";
            dataGridView1.Columns["TId"].HeaderText = "SNo";
            dataGridView1.Columns["Tcode"].Visible = false;
            dataGridView1.Columns["TID"].Width = 50;
            dataGridView1.Columns["Tcode"].Width = 70;
        }
    }

I have quiet a bit of code like this which interacts with the DB.

Question: Instead of writing these ado.net connections, sql query in the code behind, I want to use a 2 tier/3tier architecture. This should involve writing all the database stuff(ado.net execute scalar, reader, sql queries in another DBUtilitesclass/project and simply calling this DBUtilitesclass from the code behind.

Please suggest any tutorials to do this.

PS: I am using sqlite which does not support stored procedures.

Thank u Sun

Upvotes: 1

Views: 2264

Answers (1)

Related Questions