After installing, database can not be created or found!

I open a new thread, because it’s a different topic.
But after creating the installer and trying to install the software on my own computer, there is an error message and the software will not run.

The database can not be found, created or open.

“Unable to open database file”

Of-course, these are my words inside the application itself. But why does this message come now and not earlier!?
Could it be that I (inside the software) create the database in the same folder as the application is located?
I know, it’s poor programming… and I was thinking of doing this feature more stylish, but later!
Maybe I have no choice!? I need to put the database in the correct place, when using the installer?


In my “collection of bookmarks”, I manage to locate these:

A man tries to save the database in the same folder as the app. Just like me.

“Tips for using databases with REALbasic” Too much text for me to read in this moment! :slight_smile:

“Database File Size” I don’t think this one is very relevant… At least, not in this issue!

“Database Question” More recent code…

But I think I have also in my REALbasic bible… The big book!
I’ll look into these things tomorrow!

But a software like this without a working database is not generating many positive emotions… That’s for sure!! :slight_smile:

The Connecting to Databases webinar might be useful for you.

I guess your app doesn’t have write privileges for the directory your app is in.

This is likely the cause of the problem as most apps do not have the right privileges to create files right next to them
You should put your data in SpecialFolder.ApplicationSupport or one of the places it can actually write to

Thank you!
I’ll look at the webinar tomorrow!

Albin, likely! Yes!

Is there a “quick and dirty” solution to this? Because I need this only for the Windows edition. Not the others… Not at the moment.
Would it b possible to save in “My Computer / Documents” , but that name is different in different languages! :slight_smile:

So to speak…

Use SpecialFolder.ApplicationData

If you absolutely have to put it in Documents use SpecialFolder.Documents

Problems like you’re having are exactly why these things are available in SpecialFolder

Yes. Install your app in the “wrong” location. The installer should allow you to select the destination folder. Choose someplace other than Program Files, like desktop or create a folder at the root level and install in that.

If your computer have more than one defined user (sessions), Xojo is not good with you while the Finder is: it displays a dialog asking for the user owner’s password.

That sounds like a really good idea!
Of-course, it’s a truly ugly solution… !! I agree!!
But I only need to redefine the installer, not rewrite the entire application. For me, it’s a better choice in this moment.
I’m pretty sure!

Emelie! The installer is for Windows! Excuse me!
The users for Mac and Linux are left alone at this point… (There are no users so no harm is done, trust me!)

This bring up the next thread…
How do you manage different versions in the database!?
Suppose I use SpecialFolder.ApplicationData.myApplication
and at this moment it’s number 8. What when 9 comes!?
Do I open the database and copy the content from 8 to the new in 9…? All the tables and columns?

What if the user skipped from 8 and then install 12 or 13? Then columns will still be missing!
Is there a way to “look inside” a database and see what tables and columns are present and just add the once that are missing!?
I know, this is possible in MS SQL Server. You can send the command “show me all your tables” and a list will appear, "show me all your column names in table [firstTable] ".

So, in MS SQL Server it would be possible to write an editor in a web interface…
All right.
My question is, would this be possible also in SQLite and in Xojo? To open a database and to “speak” with it?
Is it possible to add version history to a database?

I mean, if I use SpecialFolder.ApplicationData.myApplication
and name all databases “database.rsd” (this is not a joke, I do!) I can then assign a version ID to the database itself.
If the version ID is too old, then delete and create a completely new database, if it’s just one step behind, then copy current data into the new database.

Are you with me!?

This is why I would prefer “quick and dirty” because these thoughts (I’ve thought of this before, much, YES!!!) require some serious thinking and will lead to errors…!! :–) Likely, a few, by experience, quite many…!

No you apply DDL/SQL scripts to update and manipulate the existing database.

Your application should recognize 8 is the current version and upgrade to 12 or 13 applying the DDL & SQL commands to get there.
It should also recognize that it is expecting 8 but the db is at 12 and warn the user that an application upgrade is required.

I must look into DDL/SQL Scripts!
Thank you!
I’ve never heard of that! Or seen!

No, the version of the software is already taken care of… but maybe that can be made in a more sophisticated manner, I’m sure!
The numbers are simply from the ID from the database I use on-line… when uploading a new versions.

You’d be surprised how much quick and dirty my software contain!
But for me, it’s a matter of survival. It works! :slight_smile:
It’s also important… to move on.

Because! An idea is all about shipping… :slight_smile:

I contributed a blog to Xojo about this some time back see

DDL is Data Definition Language e.g. Create table, alter table etc.

SQL is obviously Standard Query Language e.g. Update table, delete from etc.

Having a schema version (as you have) is critical to keeping the application & database in sync.

Thank you very much for all new information!
I’m half way through this video tutorial and i look forward to dive into the world of DDL!
I’ve used SQL for the past… 18 years, or so, so that part I know of. (How would you know??)

Let me ask!
Is there a command in Xojo to rewrite the database?
I’m sure there is a word for this, but since I don’t know the word I don’t know what to look for!

In some software, such as ThunderBird (e-mail) there is an option, “compress”. Right-click on a name… on a mailbox. You get the idea.

Is there such command in Xojo? database.compress …?

Sorry for mentioning “Finder”, but the problem can be the same (if you have more than one defined user).

Search in the previous days for VACUUM. This is the way to go.

BTW: create a new conversation for new questions (this can help others, not only you).

Managing different versions
What do you mean ? You release tomorrow version 1 of the database file, then in 2 years, you will have to release a different version that I will name version 2 (because you had to add either new Tables and/or new Fields) and in time, this version number can increase ?

I add a Table called Version with one (or two) fields and place there a value for version number. The current application read both db with version 1 and version 2 (the development is in tests).

Is this what you had in mind ?

PS: that project runs on Windows XP: client side (even if it is developed mainly on OS X and debugged on both OS) and WIndows 10 here.

I’m not sure when to start a new thread / conversation… Excuse me!

I’d like to stick to as few tables as possible. But at the other hand, I know I add tables and fields now and then… depending on the … stage of development and the need… (I assume!)