2020年3月12日13:40:27
先记录下,到时再封装
using System.Data.SQLite;
//使用sql查询语句,并显示结果
void SqLite_query()
{
try
{
SQLiteConnection conn = null;
string dbPath = "Data Source =" + Environment.CurrentDirectory + "/test.db";
conn = new SQLiteConnection(dbPath);//创建数据库实例,指定文件位置
conn.Open();//打开数据库,若文件不存在会自动创建
string sql = "select * from student order by id asc ";
SQLiteCommand command = new SQLiteCommand(sql, conn);
SQLiteDataReader reader = command.ExecuteReader();
Console.WriteLine(reader.FieldCount);
// reader.Close();
while (reader.Read())
Console.WriteLine("Name: " + reader["name"] + "\tid " + reader["id"]);
Console.ReadLine();
}
catch
{
}
}