I'm using Visual Studio 2017, in UWP project. I installed SQLite Compact Toolbox from NuGet package like this:
After that, I still can't add using Microsoft.Data.Sqlite
in MainPage.xaml.cs to read values in my table and make a query.
How can I be able to add using Microsoft.Data.Sqlite
?
The SQL Server Compact & SQLite Toolbox adds several features to help your SQL Server Compact and SQLite development efforts: Explore! Connect to SQL Server Compact 4.0, 3.5, SQL Server and SQLite database files in Visual Studio 2017 and later.
SQLite is open source file system database. Unlike SQL Server, this doesn't require any Service to interact with the database but the real problem occurs, when we try to interact with SQLite DB in C#. There is no proper Entity Framework support available, as of now. Thus, we are compelled to use inline queries.
Open Visual Studio, select new project, and, in Visual C#, select “Console Application” and provide the name as SQLiteDemo. Click OK. To connect SQLite with C#, we need drivers. Install all required SQLite resources from the NuGet package, as pictured in Figure 1. Figure 1: .NET Console application
Add SQLite/SQL Server Compact Toolbox from In Visual Studio 2017 Community. Goto Tools - Extensions and Updates - click Online. Search for Sqlite. You should see Sqlite compact toolbox. Click download . Restart visual studio.
In Microsoft Visual Studio 2017, I have included the sqlite3.lib file and directories and copied the sqlite3.dll to the project directory. I should note the included sqlite3.lib is the x86 version.
A SQLite database is integrated with the application that accesses the database. The SQLite database file format is cross-platform and can be copied between 32-bit and 64-bit file systems. Due to the serverless architecture, developers don’t need to install SQLite before using it.
Add SQLite/SQL Server Compact Toolbox from In Visual Studio 2017 Community. Goto Tools - Extensions and Updates - click Online. Search for Sqlite. You should see Sqlite compact toolbox. Click download . Restart visual studio.
Try using
using System.Data.SQLite;
Read more here https://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki
how to use sqlite in visual studio 2017
I'd recommend you to follow this latest tutorial to use a SQLite database in a UWP app.
And i can't add using Microsoft.Data.Sqlite
If you installed the Microsoft.Data.Sqlite
Nuget package, but cannot reference the Microsoft.Data.Sqlite
namespace, you may need to check the versions of UWP app,package and Microsoft.NETCore.UniversalWindowsPlatform
. As the article mentioned,if the minimum version of your project does not target the Fall Creators Update, you need to upgrade Microsoft.NETCore.UniversalWindowsPlatform
package to 5.2.2 (or higher) and install version 1.1.1 (or lower) of Microsoft.Data.Sqlite
package. Details please check The minimum version of your project does not target the Fall Creators Update section.
There're many Nuget packages for SQLite, some of them are older with long time no updating. Install many packages at a same time may lead conflicts.Try un-install them all and just following above tutorial.
There is a sample which use the old SQLite.Net-PCL
package you could also reference if you do want to use other packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With