Search code examples
databasesqliteconnection-stringproduction

Can't create sqlite db on production machine


I have a program that works correctly on my computer in Debug mode.

When my program start he create a Sqlite data base file if not exists.

This is ok on my computer.

I create a setup version for production version. The program setup is ok.

But when I start the program (.exe) my db file is not created.

This is the connection string I used :

 static string dbDirectopry = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
    static string dbName = "MySqliteDb.db";

    static string Connexion = Path.Combine(dbDirectopry, @"MySociety\MyApplication\" + dbName);

Solution

  • Hi thanks for your help,

    this is the code that create db.

    public static void CreateDb(string path)
        {
            SqLiteHelper sqlite = new SqLiteHelper(path);
            try
            {
                User.CreateTable();
            }
            catch (Exception e)
            {
                throw e;
            }
    
        }
    

    Normaly if the file doesn't exists he is automaticaly created.

    If I try my application in Debug mode with Visual Studio my db is created and I can write into.

    But when I deploy my application it doesn't work anymore. My problem is is there any special directory (for windows) to create de db file?