一切福田,不離方寸,從心而覓,感無不通。

C#操作SQLite数据库

SQLite介绍 SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite是一个开源、免费的小型RDBMS(关系型数据库),能独立运行、无服务器、零配置、支持事物,用C实现,内存占用较小,支持绝大数的SQL92标准。 SQLite数据库官方主页:http://www.sqlite.org/index.html C#操作SQLite Database C#下SQLite操作驱动dll下载:System.Data.SQLite C#使用SQLite步骤: (1)新建一个project (2)添加SQLite操作驱动dll引用 (3)使用API操作SQLite DataBase   using System; using System.Data.SQLite; namespace SQLiteSamples { class Program { //数据库连接 SQLiteConnection m_dbConnection; static void Main(string[] args) { Program p = new Program(); } public Program() { createNewDatabase(); connectToDatabase(); createTable(); fillTable(); printHighscores(); } //创建一个空的数据库 void createNewDatabase() { SQLiteConnection.CreateFile("MyDatabase.sqlite"); } //创建一个连接到指定数据库 void connectToDatabase() { m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;"); m_dbConnection.Open(); } //在指定数据库中创建一个table void createTable() { string sql = "create table highscores (name varchar(20), score int)"; SQLiteCommand command […]

龙生   11 Jul 2017
View Details