Your first SQLite program on .NET
- Download latest SQLLite – System.Data.SQLite provider from – http://sqlite.phxsoftware.com/
- You can get a good tool for SQLLite administration at – http://sqliteadmin.orbmu2k.de/.
- Refer the System.Data.SQLite.dll file in your project
- Now you should be able to do this – using System.Data.SQLite;
- 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 } } }
No related posts.
Categories: C#, Code Snippets, SQL
Recent Comments