October 1st, 2012, 02:16 AM
Connection String Setup
I am currently working on a DB application that I want to search for my database when the program starts.
My database is in the programs folder and I want it to always search for it here for instance the path should be "\db.accdb". Im using Rad Studio XE2 and I need a code I can use to do this to prevent errors when the program is moved to a different pc for example
October 1st, 2012, 07:40 AM
Nowadays it is a bad call to store your data in "Programs" folder. This is due to UAC. See my article about it here: http://forum.codecall.net/topic/6012...h-delphi-code/.
Regarding your problem, you must define a rule of how to find your database file. For example, you might want to store your db file in user's local application data under your custom subfolder. IF the db is not there, you must create fresh db file. Or you can warn your users and instruct them on how to get proper db file.
Another option is to allow users to change the db location. For this, you must provide a configuration gui so user can do the selection, and store the current value. You can store the value in your configuration file (.ini file for example), or in registry. I recommend to store in .ini file.
Last edited by Luthfi; October 1st, 2012 at 07:43 AM.
October 1st, 2012, 12:24 PM
The path will be properly stored in the registry or INI. such a choice not can trust Users
If fileExists(my_base.db)=false then
ShowMessage('Error! Not found file');