1. Refer the System.Data.SQLite.dll file in your project
  2. Now you should be able to do this - using System.Data.SQLite;
  3. Now you should be able to use ADO.NET statements in your project. Eg: SQLiteDataAdapter, SQLiteConnection etc.

 

Here goes a sample code for C#:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
using System.Data.SQLite;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            string strCon = "Data Source=C:\\your_path_to_file\\msgBC.s3db;Version=3;";
            string qry = "SELECT User, Message FROM tbl_Messages"; //your query
 
            SQLiteDataAdapter da = new SQLiteDataAdapter(qry, strCon);
 
            DataSet ds = new DataSet();
            da.Fill(ds);
 
            dataGridView1.DataSource = ds.Tables[0]; // I use a grid to show data
 
        }
    }
}
VN:F [1.1.6_502]
Rating: 5.0/5 (1 vote cast)
Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • LinkedIn
  • Live
  • MySpace
  • StumbleUpon
  • Technorati

Related posts:

  1. SQLite error no such table: tablename
  2. Enterprise Library: Your first step on DAAB
  3. Filter Listbox based on Textbox entry
  4. WinForms – Print using printDialog and printDocument
  5. MD5 encryption with c#