■ SqliteCommand 클래스의 ExecuteNonQuery 메소드를 사용해 데이터를 추가하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
using System; using System.Data.SQLite; string connectionString = "URI=file:c:\\test.db"; using(SQLiteConnection sqliteConnection = new SQLiteConnection(connectionString)) { sqliteConnection.Open(); using(SQLiteCommand sqliteCommand = new SQLiteCommand(sqliteConnection)) { sqliteCommand.CommandText = "INSERT INTO Cars VALUES(1,'Audi',52642)"; sqliteCommand.ExecuteNonQuery(); sqliteCommand.CommandText = "INSERT INTO Cars VALUES(2,'Mercedes',57127)"; sqliteCommand.ExecuteNonQuery(); sqliteCommand.CommandText = "INSERT INTO Cars VALUES(3,'Skoda',9000)"; sqliteCommand.ExecuteNonQuery(); sqliteCommand.CommandText = "INSERT INTO Cars VALUES(4,'Volvo',29000)"; sqliteCommand.ExecuteNonQuery(); sqliteCommand.CommandText = "INSERT INTO Cars VALUES(5,'Bentley',350000)"; sqliteCommand.ExecuteNonQuery(); sqliteCommand.CommandText = "INSERT INTO Cars VALUES(6,'Citroen',21000)"; sqliteCommand.ExecuteNonQuery(); sqliteCommand.CommandText = "INSERT INTO Cars VALUES(7,'Hummer',41400)"; sqliteCommand.ExecuteNonQuery(); sqliteCommand.CommandText = "INSERT INTO Cars VALUES(8,'Volkswagen',21600)"; sqliteCommand.ExecuteNonQuery(); } sqliteConnection.Close(); } |