Search This Blog

Showing posts with label SQLite. Show all posts
Showing posts with label SQLite. Show all posts

Friday, July 29, 2016

SQLITE Get All Tables

SQLITE > Get all tables

SELECT name FROM sqlite_master  WHERE type='table'

Friday, July 8, 2016

SQLite C# Example

C# > SQLite

SQLiteConnection.CreateFile("MyDatabase.sqlite");
SQLiteConnection  m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");

m_dbConnection.Open();

string sql = "create table project (name varchar(100), id int)";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();

sql = "insert into project (name, id) values ('project 1', 1)";
command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();

sql = "select * from project order by id desc";
command = new SQLiteCommand(sql, m_dbConnection);
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())

 Console.WriteLine("Name: " + reader["name"] + "\tScore: " + reader["id"]);