■ SQLiteDataReader 클래스를 사용해 데이터를 조회하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
using System; using System.Data.SQLite; string connectionString = "Data Source=c:\\test.db;Version=3" using(SQLiteConnection connection = new SQLiteConnection(connectionString)) { connection.Open(); string sql = "SELECT ID, Name, Grade FROM Student ORDER BY Name"; SQLiteCommand command = new SQLiteCommand(sql, connection); SQLiteDataReader reader = command.ExecuteReader(); while(reader.Read()) { Console.WriteLine("ID={0}, Name={1}, Grade={2}", reader["ID"], reader["Name"], reader["Grade"]); } } |