6

I'm using Visual Studio 2017, in UWP project. I installed SQLite Compact Toolbox from NuGet package like this:

  • Microsoft.Data.sqlite / sqlite-net / sqlite-net-pcl / System.Data.SQLite

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?

Andrew
  • 18,680
  • 13
  • 103
  • 118
CorentinMerit
  • 99
  • 1
  • 1
  • 4

4 Answers4

11

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.

David Morrow
  • 262
  • 4
  • 9
1

Try using

using System.Data.SQLite;

Read more here https://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki

J.B.
  • 57
  • 5
1

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.

Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21
0

It is 2021 and I'm on VS2017 still. The only thing I could get to work in the tutorial recommended by Wu was using the part of the tutorial about using the version of sqlite included with Windows. Everything else would no longer install with uwp 10.

As of 1/25/2021:

Target Windows 10, version 10.0

Target Windows 10 Fall Creators Update 10.0

Use nuget and install these two packages:

Microsoft.Data.SQLite.core

SQLitePCLRaw.bundle_winsqlite3

I will say it worked to the point I loaded a DataTable with data and debug showed it had two rows in it.

I spent all afternoon trying to get sqlite to work. It's amazing anyone ever actually gets anything done. No wonder companies have to have rooms full of coders!

user1544428
  • 110
  • 1
  • 8