using System.Data.SQLite; SQLiteConnection connection = new SQLiteConnection("Data Source=database.db"); connection.Open(); SQLiteCommand command = new SQLiteCommand("SELECT * FROM users", connection); SQLiteDataReader reader = command.ExecuteReader(); reader.Close(); // Disposes of the SQLiteCommand instance command.Dispose(); connection.Close();
using System.Data.SQLite; SQLiteConnection connection = new SQLiteConnection("Data Source=database.db"); connection.Open(); using (SQLiteCommand command = new SQLiteCommand("SELECT * FROM users", connection)) { SQLiteDataReader reader = command.ExecuteReader(); reader.Close(); } connection.Close();In this example, we use a using statement to create an instance of the SQLiteCommand class. When the block of code has executed, the SQLiteCommand will automatically be disposed of. The SQLiteCommand class is part of the System.Data.SQLite package library.