What is the best way to connect and use a sqlite database from C#
Microsoft.Data.Sqlite by Microsoft has over 9000 downloads every day, so I think you are safe using that one.
Example usage from the documentation:
using (var connection = new SqliteConnection("Data Source=hello.db"))
{
connection.Open();
var command = connection.CreateCommand();
command.CommandText =
@"
SELECT name
FROM user
WHERE id = $id
";
command.Parameters.AddWithValue("$id", id);
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
var name = reader.GetString(0);
Console.WriteLine($"Hello, {name}!");
}
}
}
How can I access SQLite with C#?
You can not connect to sqlite db using SQLProvider classes. They are for sql server. You need to use SQLite provider classes.
Related Topics
Why Can't I Use Interface with Explicit Operator
Getting Time Span Between Two Times in C#
Invalid Cast from 'System.Int32' to 'System.Nullable'1[[System.Int32, Mscorlib]]
Save Detached Entity in Entity Framework 6
How to Bind an Enum to a Dropdownlist Control in ASP.NET
Error Message "Cs5001 Program Does Not Contain a Static 'Main' Method Suitable for an Entry Point"
Database.Begintransaction VS Transactions.Transactionscope
.Net (3.5) Formats Times Using Dots Instead of Colons as Timeseparator for It-It Culture
Auto-Resize Multiple Forms Rendered on Panel
Simplest Way to Run Three Methods in Parallel in C#
How to Use Async to Increase Winforms Performance
Wcf - Design Parameter Decision
How to Click on the Radio Button Through the Element Id Attribute Using Selenium and C#
Forms' Does Not Exist in the Namespace System.Windows
Combining Datatemplates at Runtime
Generate Class from Database Table
C# - Which Is the Best Alternative to 'Switch on Type'
JSON.Net Adding Backslash While Returning JSON Serialized String