{
  string dbPath = Server.MapPath("~") + "\\App_Data\\blog.db";
  bool dbExists = System.IO.File.Exists(dbPath);
  System.Data.SQLite.SQLiteConnection conn = 
        new System.Data.SQLite.SQLiteConnection();
  conn.ConnectionString = "Data Source="+dbPath;
  // conn.SetPassword("my_password");
  conn.Open();

  if (!dbExists)
  {
    CreateDatabase(conn);
  }

  Application.Add("db", conn);
}

void CreateDatabase(System.Data.SQLite.SQLiteConnection conn)
{
  using (System.Data.SQLite.SQLiteCommand cmd = conn.CreateCommand())
  {
    cmd.CommandText = "create table BlogInfo (Title text, Subtitle text,
         Email text, Copyright text)";
    cmd.ExecuteNonQuery();
    cmd.CommandText = "create table BlogCategory (ID integer primary key 
         autoincrement, Name text, Description text)";
    cmd.ExecuteNonQuery();
    cmd.CommandText = "create table BlogEntry (ID integer primary key 
         autoincrement, Title text, Subtitle text, CategoryID integer, 
         Date datetime, BlogText text)";
    cmd.ExecuteNonQuery();
    cmd.CommandText = "insert into BlogInfo (Title, Subtitle, Email, 
         Copyright) values ('Title', 'Subtitle', 'your email', 
         'your copyright')";
    cmd.ExecuteNonQuery();
  }
}

void Application_End(object sender, EventArgs e) 
{
  System.Data.SQLite.SQLiteConnection conn = 
     (System.Data.SQLite.SQLiteConnection)Application["db"];
  conn.Close();
}