#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2009
    Posts
    77
    Rep Power
    5

    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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    2
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0
    Code:
    If fileExists(my_base.db)=false then
    begin
          ShowMessage('Error! Not found file');
          exit;
    end;
    //next connect
    The path will be properly stored in the registry or INI. such a choice not can trust Users

IMN logo majestic logo threadwatch logo seochat tools logo