SQLiteConnection sqlite_conn; SQLiteCommand sqlite_cmd; SQLiteDataReader sqlite_datareader; // create a new database connection: sqlite_conn = new SQLiteConnection("Data Source=database1.db;Version=3;New=True;Compress=True;"); // open the connection: sqlite_conn.Open(); // create a new SQL command: sqlite_cmd = sqlite_conn.CreateCommand(); // Let the SQLiteCommand object know our SQL-Query: sqlite_cmd.CommandText = "CREATE TABLE test (id integer primary key, text varchar(100));"; // Now lets execute the SQL ;D sqlite_cmd.ExecuteNonQuery(); // Lets insert something into our new table: sqlite_cmd.CommandText = "INSERT INTO test (id, text) VALUES (6, 'Test Text 7');"; // And execute this again ;D sqlite_cmd.ExecuteNonQuery(); // ...and inserting another line: sqlite_cmd.CommandText = "INSERT INTO test (id, text) VALUES (7, 'Test Text 2788');"; // And execute this again ;D sqlite_cmd.ExecuteNonQuery(); sqlite_cmd.CommandText = "SELECT * FROM test"; sqlite_datareader = sqlite_cmd.ExecuteReader(); while (sqlite_datareader.Read()) { MessageBox.Show(sqlite_datareader["text"].ToString()); System.Console.WriteLine(sqlite_datareader["text"]); } // We are ready, now lets cleanup and close our connection: sqlite_conn.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)