■ SQLiteDataReader 클래스 : 데이터 조회하기

----------------------------------------------------------------------------------------------------

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"]);

    }

}

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요