Hi @Alexandre Dantas , Welcome to Microsoft Q&A,
Use absolute paths: Make sure that the database file paths used in the program are absolute paths and not relative paths. You can use methods such as Path.Combine
to build absolute paths.
using System.IO;
// Get the directory where the executable file is located
string baseDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
// Build absolute path
string dbPath = Path.Combine(baseDirectory, "YourDatabase.db");
Database connection string: Make sure your database connection string is correct and contains the correct database path. You can use absolute paths directly in the connection string.
string connectionString = "Data Source=C:\\path\\to\\your\\database.db;Version=3;";
SQLite3 driver: Make sure the SQLite3 driver is installed on the target computer. You can include SQLite3's DLL file in your project, or make sure SQLite3 is already installed on the target computer.
To put it simply, you can also refer to these two old questions: Saving and Publishing SQLite Database
How To Publish/Create Installer For A C# Application With An SQLite Database?
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.