mercredi 30 mars 2016

Sqlite c# creates 2 same named databases

I have a problem that when i want to create database and specify its name it is created in the specified directory and in directory where the aplication is running. Why is that happening?

Code that creates database:

    private static string AddDb(string dbName, string dbPassword)
    {
        try
        {
            string startupPath = Environment.CurrentDirectory;
            string dataBasePath = startupPath + "\\DB\\" + dbName;
            SQLiteConnection.CreateFile(dataBasePath);
            SQLiteConnection dbConnString;
            dbConnString = new SQLiteConnection("Data Source =" + dbName + ";Version=3;");
            dbConnString.Open();
            dbConnString.ChangePassword(dbPassword);
            dbConnString.Close();
            return dataBasePath;
        }
        catch
        {

            MessageBox.Show("Failed to create database", "DB Creator");
            return "";
        }
    }

Aucun commentaire:

Enregistrer un commentaire