connect to sqlite database in csharp

To connect to a SQLite database in C#, you can use the System.Data.SQLite library. Here's an example code snippet that shows how to make a connection using ADO.NET:

main.cs
using System.Data.SQLite; // Import the SQLite library

string connectionString = "Data Source=database.db;Version=3;"; // Set the connection string to the SQLite database
SQLiteConnection connection = new SQLiteConnection(connectionString); // Create a new connection object
connection.Open(); // Open the connection

// Do whatever you need to do with the connection

connection.Close(); // Close the connection when you're done
431 chars
10 lines

In the connection string, replace database.db with the path to your SQLite database file. This assumes that you have the SQLite library installed and referenced in your project.

gistlibby LogSnag