dcsimg
Results 1 to 3 of 3

Thread: Where my SQLite database should be placed?

  1. #1

    Thread Starter
    Addicted Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    147

    Where my SQLite database should be placed?

    Hello!

    I'm trying to run my Application in debug mode within VS 2019 I'm using an SQLite database (called: Owner.db), before I use to have the following connection string:
    "Data Source=C:\SystemWin\DB2\Owner.db;Version=3;" and it used to work just fine! but... since I don't really want to hardcode my connection string, I decided to use '|DataDirectory|'

    My question is where my database should be placed? so the following connection string works.
    "Data Source = |DataDirectory|\Owner.db;Version=3;"

    I've tried putting it into:
    C:\Users\Windows_User\Documents\Visual Studio 2019\Projects\Project_name\bin\Debug
    with no success.

    Thank you.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,602

    Re: Where my SQLite database should be placed?

    Is your EXE file being run from the 'C:\SystemWin\DB2' folder? If not then that won't work with explicitly setting the data directory to that location in code.

    https://social.msdn.microsoft.com/Fo...y-?forum=sqlce

    That question was actually about SQL Server CE but this SO question referring to it suggests that SQLite supports "|DataDirectory|" too.

  3. #3

    Thread Starter
    Addicted Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    147

    Re: Where my SQLite database should be placed?

    After I changed my connection string to: "Data Source = |DataDirectory|\Owner.db;Version=3;" I also moved the database to the bin\Debug folder, I knew that the database shouldn't be in: C:\SystemWin\DB2. but it still doesn't work in debug mode.

    Name:  Capture.PNG
Views: 28
Size:  8.9 KB

    I even tried with: "Data Source = |DataDirectory|\\Owner.db;Version=3;"
    and still doesn't work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width