728x90
데이트를 관리하기 의해서 DataBase를 사용한다.
그 중에 하나인 SQLite를 소개한다.
DB 엔진을 별도로 설치하지 않고 사용한다.
아래 사이트가 공식사이트이다.
https://www.sqlite.org/index.html
SQLite Home Page
SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. SQLite is the most used database engine in the world. SQLite is built into all mobile phones and most computers and comes bu
www.sqlite.org
SQLite 관리 다운로드 페이지
VSCode에서 사용하기 위해서 Project 폴더에서 아래 명령을 실행해서
System.Data.Sqlite를 설치한다.
dotnet add package System.Data.Sqlite
예제
using System.Data.SQLite;
namespace SqliteCSharp
{
class Program
{
static void Main(string[] args)
{
string strConn = @"Data Source=.\test.db";
using (SQLiteConnection conn = new SQLiteConnection(strConn))
{
conn.Open();
string strSQL = "CREATE TABLE memo (txt string)";
SQLiteCommand sqlcmd = new SQLiteCommand(strSQL, conn);
sqlcmd.ExecuteNonQuery();
sqlcmd.Dispose();
strSQL = "INSERT INTO memo VALUES ('SQLite C# Sample.')";
sqlcmd = new SQLiteCommand(strSQL, conn);
sqlcmd.ExecuteNonQuery();
sqlcmd.Dispose();
strSQL = "SELECT * FROM memo";
sqlcmd = new SQLiteCommand(strSQL, conn);
SQLiteDataReader rd = sqlcmd.ExecuteReader();
sqlcmd.Dispose();
while (rd.Read())
{
Console.WriteLine(rd["txt"]);
}
rd.Close();
}
}
}
}
728x90
반응형
'Software > C#' 카테고리의 다른 글
ASP.NET Core 시작하기 - REST API (0) | 2024.07.27 |
---|---|
VSCode에서 C# 시작하기 - MySQL 연결하기 (0) | 2024.05.24 |
C# 시작하기 - Winform 미로그리기 3D (1) | 2023.12.07 |
C# 시작하기 - Winform 바둑판 그리기(2) (1) | 2023.12.06 |
C# 시작하기 - Winform 바둑판 그리기(1) (1) | 2023.12.06 |