첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ In-Memory 데이터베이스 사용하기

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

using System;

using System.Data.SQLite;

 

string connectionString = "Data Source=:memory:";

 

SQLiteConnection sqliteConnection = null;

SQLiteCommand    sqliteCommand    = null;

 

try

{

    sqliteConnection = new SQLiteConnection(connectionString);

 

    sqliteConnection.Open();

 

    string sql = "SELECT SQLITE_VERSION()";

 

    sqliteCommand = new SQLiteCommand(sql, sqliteConnection);

 

    string version = sqliteCommand.ExecuteScalar().ToString();

 

    Console.WriteLine("SQLite version : {0}", version);

}

catch(SQLiteException sqliteException)

{

    Console.WriteLine("Error: {0}", sqliteException.ToString());

}

finally

{

    if(sqliteCommand != null)

    {

        sqliteCommand.Dispose();

    }

 

    if(sqliteConnection != null)

    {

        try

        {

            sqliteConnection.Close();

        }

        catch(SQLiteException sqliteException)

        {

            Console.WriteLine("Closing connection failed.");

            Console.WriteLine("Error: {0}", sqliteException.ToString());

        }

        finally

        {

            sqliteConnection.Dispose();

        }

    }

}

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

Posted by 사용자 icodebroker

댓글을 달아 주세요