SQLite Version Check(SELECT SQLITE_VERSION())
/*1. SQLite를 설치한(Install) 후에
2. SQLite DLL을 프로젝트에 참조한 후에*/
using System;
using System.Data.SQLite;
class Program
{
public static void Main()
{
SQLiteManageCls nm = new SQLiteManageCls();
nm.running();
}
}
class SQLiteManageCls
{
string connectionString = "Data Source=:memory:";
SQLiteConnection sqliteConnection = null;
SQLiteCommand sqliteCommand = null;
public void running()
{
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();
}
}
}
}
}