Setup SQLite Database in Visual Studio (14/23)



Setup SQLite Database in Visual Studio (14/23)

Setup SQLite Database in Visual Studio (14/23)

In this video we will cover how to setup a SQLite database for your application.

Steps:

1. Install the System.Data.SQLite NuGet package:
    a. Right-click on your project in the Solution Explorer and select “Manage NuGet Packages”.
    b. Click on the “Browse” tab and search for “System.Data.SQLite”.
    c. Select the “System.Data.SQLite” package and click “Install”. 
    d. Description should say The official SQLite database engine for both x86 and x64 along with the ADO.NET provider.  This package includes support for LINQ and Entity Framework 6.

2. Install the SQLite extension:
    a. In Visual Studio, go to “Tools” then “Extensions and Updates”.
    b. In the “Manage Extensions” window, search for “SQLite” in the search box.
    c. Find “SQLite/SQL Server Compact Toolbox” in the search results and click the “Install” button. 
    d. You may need to restart Visual Studio to complete the installation.

3. Open the SQLite/SQL Server Compact Toolbox:
    a. In Visual Studio, go to “View” then “Other Windows” then “SQLite/SQL Server Compact Toolbox”.

4. Add your SQLite database to the Toolbox:
    a. In the “SQLite/SQL Server Compact Toolbox” window, right-click on “Data Connections” and choose “Add SQLite Connection”.
    b. In the “Add SQLite Connection” window, click “Create” or “Browse” and locate your SQLite database file (e.g., “LibraryManagementSystem.db”). 
    c. Click “Open” and then “Test Connection” to ensure the connection is working correctly. 
    d. Finally, click “Close” to add the connection.

5. Add a new SQLite database file to your project:
    a. Add database file manually 
    b. Or Run databaseHelper file (code available in video)

6. Browse and manipulate the SQLite data:
    a. In the “SQLite/SQL Server Compact Toolbox” window, you should now see your SQLite database under “SQLite Connections”. Expand the tree by clicking the arrow to see the tables in the database.
    b. To view the data in a table, right-click on the table and select “Edit top 200 rows”. This will open a new window displaying the data in the table, similar to how you would view a CSV file.

7. To view the data inside the SQLite database, you can use a third-party tool like 
    a. DB Browser for SQLite 
    b. SQLite extension for Visual Studio Code

C# .NET
Windows Form Application
Visual Studio
SQLite

Comments are closed.