using System.Data.SQLite; string connectionString = "Data Source=myDatabase.sqlite;Version=3;"; string sql = "INSERT INTO MyTable (Column1, Column2) VALUES (@p1, @p2);"; using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { connection.Open(); using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { command.Parameters.AddWithValue("@p1", "value1"); command.Parameters.AddWithValue("@p2", "value2"); int rowsAffected = command.ExecuteNonQuery(); Console.WriteLine($"Rows affected: {rowsAffected}"); } }
using System.Data.SQLite; string connectionString = "Data Source=myDatabase.sqlite;Version=3;"; string sql = "UPDATE MyTable SET Column1=@p1 WHERE Column2=@p2;"; using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { connection.Open(); using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { command.Parameters.AddWithValue("@p1", "new value"); command.Parameters.AddWithValue("@p2", "value2"); int rowsAffected = command.ExecuteNonQuery(); Console.WriteLine($"Rows affected: {rowsAffected}"); } }In this example, we are updating data in an SQLite table named 'MyTable'. We are using the SQLiteConnection.Execute method to execute the SQL statement and update the data. Package library: The SQLiteConnection.Execute method is a part of the System.Data.SQLite package library. This library provides a set of ADO.NET providers for accessing SQLite databases. It is available as a NuGet package in the Microsoft Visual Studio Package Manager.