前端之家收集整理的这篇文章主要介绍了
操作sqlite,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
static string connStr = "Data Source=d:\\test.db";
static void Main(string[] args) {
sqliteConnection conn = new sqliteConnection(connStr);
sqliteCommand cmd = conn.CreateCommand();
string sql = "select * from admin";
conn.Open();
cmd.CommandText = sql;
IDataReader dr = cmd.ExecuteReader();
//输出列名,FieldCount 是列长度
for (int i = 0; i < dr.FieldCount; ++i)
Console.Write(dr.GetName(i) + "\t");
Console.WriteLine();
//输出一行,先read
while (dr.Read()) {
Console.Out.WriteLine(dr.GetString(0) + "\t" + dr.GetString(1));
}
Console.Read();