Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

c# - How to bind a DataGridView to a SQLite Database?

I'm trying to add a data connection to a datagridview that uses SQLite. I've added the reference to SQLite (downloaded the required files) but when I go through the wizard to add a data source, SQLite is not included in the choices - see screenshot below:

Change Data Source

I've looked around for answers to this question but have not been successful in finding any.

Here is a screenshot of the database inside my project folder:

project folder

Is there any way to bind the datagridview to a sqlite data source?

Any help would be appreciated.

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The steps below are copied from http://geekswithblogs.net/danielggarcia/archive/2013/12/22/portable-databases-ii-using-sqlite-with-entity-framework.aspx:

  1. Go to Tools > Library Package Manager > Manage NuGet Packages for solution...
  2. Choose the Online section and write SQLite inside the textbox located on the upper-right corner. Push ENTER and wait for the search to be performed.
  3. Choose the first package: System.Data.SQLite (x86/x64).
  4. Once the package has been downloaded, select the project in which to install the provider and press OK.

If the data source still isn't available after following the above steps don't work, it may be a problem with the SQLite version - see the comment left by cmc and the linked thread, which says version 1.0.93 works but version 1.0.94 doesn't.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...