static void Main(string[] args) { ListBooks(); FindBookByName("Pod Igoto"); Book book = new Book("Added book", "Minka Svircholini", "8411929473", new DateTime(2013, 01, 12)); AddBook(book); }
static void AddBook(Book book) { SQLiteConnection connection = new SQLiteConnection(); connection.Open(); using (connection) { SQLiteCommand command = new SQLiteCommand( "INSERT INTO Books (Title, Author, PublishDate, ISBN) " + "VALUES (@title, @author, @publishDate, @isbn)", connection); SQLiteParameter titleParam = new SQLiteParameter("@title", book.Title); SQLiteParameter authorParam = new SQLiteParameter("@author", book.Author); SQLiteParameter publishDateParam = new SQLiteParameter("@publishDate", book.PublishDate); SQLiteParameter isbnParam = new SQLiteParameter("@isbn", book.Isbn); command.Parameters.AddRange(new SQLiteParameter[] { titleParam, authorParam, publishDateParam, isbnParam }); command.ExecuteScalar(); } }