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
{
}
}