Using Using Namespace Class: Program Sqliteconnection
Using Using Namespace Class: Program Sqliteconnection
// This sample is part Part One of the 'Getting Started with SQLite in C#' tutorial at
http://www.blog.tigrangasparian.com/
using System;
using System.Data.SQLite;
namespace SQLiteSamples
{
class Program
{
// Holds our connection with the database
SQLiteConnection m_dbConnection;
public Program()
{
createNewDatabase();
connectToDatabase();
createTable();
fillTable();
printHighscores();
}
// Creates a table named 'highscores' with two columns: name (a string of max 20 characters)
and score (an int)
void createTable()
{
string sql = "create table highscores (name varchar(20), score int)";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
}