Bad SQLite Example [C#] 01-19-2014, 02:25 PM
#1
Been messing around with Mono recently, and decided to see if i could somehow get System.Data.SQLite to work. Turns out i couldn't ^_^
Anyways that resulted with me having a Working C# SQLite Reader.
Add a reference to System.Data.SQLite.dll to the project, and then add to the top of the project.
Create a SQLite Database named "dud.sq3", with a table named "a", and 2 rows, i (Interger Primary Auto Increment), b (Numeric), and put it in the Debug folder.
Add a listbox named listBox1 to the form, and then In The Initialization Area, under InitializeComponent();, add:
If any decent C# programmer thinks this code is complete crap, i won't blame them
Still actually learning C#, originally a VB.Net programmer.
Anyways that resulted with me having a Working C# SQLite Reader.
Add a reference to System.Data.SQLite.dll to the project, and then add
Code:
using System.Data.SQLite;
Create a SQLite Database named "dud.sq3", with a table named "a", and 2 rows, i (Interger Primary Auto Increment), b (Numeric), and put it in the Debug folder.
Add a listbox named listBox1 to the form, and then In The Initialization Area, under InitializeComponent();, add:
Code:
var ConnStr = "Data Source={0};version=3;New={1};Compress={2}";
var Dud = new SQLiteConnection
{
ConnectionString = string.Format(ConnStr, Path.Combine(Application.StartupPath, "dud.sq3"),false,false)
};
using (var Query = new SQLiteCommand())
{
Dud.Open();
Query.Connection = Dud;
Query.CommandText = string.Format("SELECT * FROM {0}", "a");
var DudReader = Query.ExecuteReader();
while (DudReader.Read())
{
listBox1.Items.Add(DudReader.GetValue(1).ToString());
}
Dud.Close();
}
If any decent C# programmer thinks this code is complete crap, i won't blame them
![Tongue Tongue](https://sinister.ly/images/smilies/set/tongue.png)