/*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();
}
}
}
}
}
'c# 언어 > 중급과정' 카테고리의 다른 글
c# using - statement(File및 Font와 같은 클래스들에 유용) (0) | 2022.04.11 |
---|---|
SQLite Conn,Open,Create Table,Data Insert,Select (0) | 2022.04.07 |
tcp:sendfile-server src sample (0) | 2022.04.05 |
tcp:sendfile-client src sample (0) | 2022.04.05 |
Console RemoteKey & Tris Server Frm(No Key) & Auto Start (0) | 2022.03.28 |