no such table
I'm not sure why i'm getting this, I do have a table called users. Am I formatting the query wrong?
31 Replies
$sqlinjection
Always parametrize queries!⠀
Do not concatenate the query, like in this example:
Instead, always parameterize your queries. Look up the documentation for your database library. If you are using
System.Data.SqlClient
, refer to this example.SQL Injection is very important to know if you are messing with databases
It's not going anywhere, its a beginner project
Great to know nonetheless
that's true
Have you saved/wrote the changes in the SqliteBrowser?
yeah, if I open the db file it has the table in it
Where does it exist?
The db file that is
Have you selected the correct file? Tried using an absolute path? - I'm almost sure you're creating an empty DB.
That's why then
the database is relative to your executable location
Since this is what the Sqlite does when it's not found, no error message, just a blank db file.
Database cannot be embedded within the application
unless it's an in-memory DB
Where should I put the database? If i want it to work on another machine
Next to the csproj and set it to copy on build
Buddy
the database is relative to your executable location
Quoted by
<@203166497198047232> from #no such table (click here)
React with ❌ to remove this embed.
Isn't the working directory the debug path?
executable path
Oh, right
Unless you changed it manually, the relative path to the csproj is the same as relative path to the exe when built
So
becomes
it works when it's like this, with the full path. How can I format the path so it is relative
./LoginDatabase.db
should do
Even LoginDatabase.db
alone tbhRemember, the database will not be embedded.
It must be located on disk
So right-click on the database file and set it to be copied always
Or you can create a blank the file in the AppData folder and execute the SQL statements for the structure.
Then you don't depend on anything and the structure is hardcoded/embedded in your application. ¯\_(ツ)_/¯
Or better yet, have it create that file on first run in the same directory as the exe
Might be my bias speaking, though. I fucking hate it when apps cram everything and their mother onto the C: drive
Looking at you, my 18 GB Space Engineers mod folder that I had to symlink
doing this fixes it. It works now
hehe, but that's what the AppData is for :X
i'm not entirely sure why/ whats going on behind the scenes though. Will these be fine to do for a small database?
Sure
Okay, thank you
when you clean + build, your data will be erased :(