Setup SQLite Database in Visual Studio (14/23)

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 มิ.ย. 2024
  • Timestamps:
    0:00 Intro to SQLite
    1:22 Install SQLite Extension
    2:45 Install Database Viewer
    3:41 Initialize Database Manually
    6:28 Automate Database Initialization
    7:26 Connection String
    8:29 Code Review
    9:53 Run Code to Create DB file
    10:30 Add DB Viewer Connection
    10:55 Overview
    12:01 DB Browser
    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

ความคิดเห็น • 18

  • @emilie1977
    @emilie1977 7 หลายเดือนก่อน +1

    Thank you! You saved me

  • @OrisonAlmeida
    @OrisonAlmeida 7 หลายเดือนก่อน +1

    Thanks!

  • @shahzaibhassan6504
    @shahzaibhassan6504 ปีที่แล้ว +1

    Finnaly an Dated tutorial.

  • @2003Abdulla
    @2003Abdulla หลายเดือนก่อน +1

    legend

  • @UlisesGB.
    @UlisesGB. 7 หลายเดือนก่อน +1

    Thank you very much for the video! You just saved my life. Pura vida!

  • @user-uu4fu9wv7v
    @user-uu4fu9wv7v 2 หลายเดือนก่อน

    i can't find the sqlite after i install it in tools or in vew ? help me plz

  • @222amonra
    @222amonra 3 หลายเดือนก่อน

    "Unable to find the requested .NET framework data provider. It might not be installed" error. I'm using .NET framework 4.8 and using VB script.

  • @louureghz
    @louureghz 6 หลายเดือนก่อน +1

    my question is, how are you able to publish it in a package(exe. File) with the database?

    • @rorymulcahey
      @rorymulcahey  5 หลายเดือนก่อน

      The exe file looks for the db file that your connection string points to, which in my case is this:
      "private string _connectionString = @"Data Source=..\..\Files\LibraryManagementSystem.db;Version=3;";"
      It uses a referential path (..\..\) rather than a precise one (C:\..\) so the code is portable to other locations.

  • @yanamyron768
    @yanamyron768 6 หลายเดือนก่อน

    Dont u know what to do with the error " namespace "System::Data" has no member "SQLite" even after instaling System.Data.SQLite? It's c++ clr empty progect.

    • @rorymulcahey
      @rorymulcahey  5 หลายเดือนก่อน

      Check your install:
      Go to Project > Manage NuGet Project and see if System.Data.SQLite is installed.
      Go to Solution Explorer (on right by default) > References and see if System.Data.SQLite is installed.

  • @zerogliff
    @zerogliff 4 หลายเดือนก่อน

    I use SQLiteStudio instead of DB browser

  • @irfannaseef
    @irfannaseef 14 วันที่ผ่านมา

    Please share the database helper code file

    • @rorymulcahey
      @rorymulcahey  14 วันที่ผ่านมา

      shorturl.at/GcNA1

  • @muhammadhadiputrajamal6638
    @muhammadhadiputrajamal6638 4 หลายเดือนก่อน

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred.
    Error occurred during LocalDB instance startup: SQL Server process failed to start.
    Why 😭🥲

    • @rorymulcahey
      @rorymulcahey  4 หลายเดือนก่อน

      This video is about SQLite, not SQL Server. Based on your error it appears you are trying to setup SQL Server.

    • @zeelock2926
      @zeelock2926 2 หลายเดือนก่อน

      I had a similar problem. The problem was that I was using SqlConnection instead of SQLiteCommand. It looks like all sql... has the same but SQLite... just one is for servers and one is for the light version.