using (SQLiteConnection cnn = new SQLiteConnection("Data Source=mydatabase.db"))
using (SQLiteCommand cmd = cnn.CreateCommand())
{
cnn.Open();
// Create a new table
cmd.CommandText = "CREATE TABLE FOO ([ID] INTEGER PRIMARY KEY, [MyValue] NVARCHAR(256)";
cmd.ExecuteNonQuery(); // Create the table, don't expect returned data
// Insert something into the table
cmd.CommandText = "INSERT INTO FOO (MyValue) VALUES('Hello World')";
cmd.ExecuteNonQuery();
// Read the values back out
cmd.CommandText = "SELECT * FROM FOO";
using (SQLiteDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine(String.Format("ID = {0}, MyValue = {1}", reader[0], reader[1]));
}
}
}