-
I am creating a system which reads an ACCESS database and processes data on several different forms, using various types of data control (Adodc1, Data1 etc.)
How can I set the Connection srting(s) at design time to look at the IniFile settings "Datapath", so I can distribute the app and have it dynamically point to the correct database?
Help please as I'm going crazy trying to figure this out!
-
First off... you probably don't want to use an INI file. If the file gets damaged or lost, your program just doesn't work. Why not have the database install in the directory with the application, so you can use App.Path? Then it won't matter where the user installs your app, as long as they install it all together.
As far as setting data paths at runtime, just make sure you do not set any data paths for your data controls at design time. They should all be blank. This will prevent your from 'forgetting' to set one of them, or some of the related properties for bound controls. Many times I've tested thoroughly, only to find things blowing up once the application was installed on a new machine because a data path was still looking for a file in a location that only existed on my hard drive.
Set the databasename property of the data control and then refresh the connection.
Bash
-
I would disagree about using a .ini file. They're very small and if you have any kind of source control, very easy to recover. If one gets corrupted (or deleted) it's very easy (and quick) to pop one in the mail.
When using bound controls, I agree with you. I only set the database name long enough to retrieve fields and then I *always* reset it to blank.