//C# publicvoidreadNameFromDatabase() { SQLiteConnection conn = getDatabase(); conn.Open();//打开数据库,若文件不存在会自动创建 string sql = "select id name from testTable"; SQLiteCommand cmdQ = new SQLiteCommand(sql, conn); SQLiteDataReader reader = cmdQ.ExecuteReader(); while (reader.Read()) { int id = reader.GetInt32(0); string a = reader.GetString(1); string b = reader.GetString(2); string c = reader.GetString(3); //……………… } conn.Close();
// Console.ReadKey(); }
改
1 2 3 4 5 6 7 8 9 10 11 12
//C# privatevoidupdateDatabase(int a) { SQLiteConnection conn = getDatabase(); conn.Open(); string sql = "update testTable set a = 5,b = 6,c = 7 where id = " + a; SQLiteCommand cmdInsert = new SQLiteCommand(conn); cmdInsert.CommandText = sql; cmdInsert.ExecuteNonQuery(); conn.Close(); }