Tricky ConnectionString/config file problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

Does anyone know how to handle the following?

I have an application that is made up of two parts. The "base" (class
library) and the "main" (windows app). The base consists of a number of
windows forms, one of them being the base main form that the windows app
derives from. Most of the forms in the base connect to an Access database.
The connection for each was non-dynamic and was automatically hard coded to
the actual path to the database when the connection was created. This worked
fine.

What I am trying to do now is create a setup project to allow users to
install my application. In order to do that, I want to change the connection
string to ".\database.mdb" so I figured the best way to do that would be to
change to a dynamic connection string which would be stored in the .config
file. This is where I am running into problems.

The connection string is associated with the base. How do I handle the
..config file to work with the main app? Is the naming convention important
for the config file? Do I name it after the main app? After the base DLL? My
understanding is that the config file is supposed to be named after the
application. Any help would be greatly appreciated.

Thank you,

Carlo.
 
You can add a config file for each one if you needed although that's
probably not necessary. The config files will be named automatically when
they are compiled ie myappp.exe.config
 
Carlor,

The config file convention is <<exename>>.config, so as Bill said
myapp.exe.config is a good example.
If a dll is loaded by an EXE, then the dll reads config information from
thatexename.config.

If this model doesn't quite work for you, nothing really prevents you from
coming up with your own config scheme.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
Hi Sahil,

Thanks for the reply, but could you just clarify for me?

My base dll called appbase.dll is the one that needs the connection string
from the config file. My main app called mainapp.exe has its main form
derived from one in appbase.dll. Are you saying then, that I should put the
connection string in mainapp.exe.config?

Thank you,

Carlo.
 
No need to clarify for me. I tried it and I now have it working... except it
has introduced a new problem. I'll be posting a new question about it.

Thanks for all your help.

Carlo.
 
Back
Top