3.11.08

Interacting with SQLite.NET API

A typical db session using SQLite.NET is shown below. The interaction idioms are similar to the ADO.NET API and this makes direct knowledge application from ADO.NET to SQLite.NET trivial.

int retCode;
using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
{
connection.Open();
using (SQLiteTransaction transaction = connection.BeginTransaction())
{
using (SQLiteCommand cmd = new SQLiteCommand(commandText, connection))
{
retCode = cmd.ExecuteNonQuery();
}
transaction.Commit();
}
} return (retCode > 0 ? true : false);

No comments: