views:

138

answers:

1

I'm trying to set a DataAdapter connection string to point to %APPDATA% from within Visual Studio designer by editing the DataAdapter properties. I cannot seem to be able to use that moniker on the connection string property. It doesn't get translated to C:\Users\MyUserName\AppData\Roaming when I then run the application in debug mode.

How can I ensure that these type of strings can be set within the designer so they are not hardcoded and do not jeopardize any future Setup project?

Note: I know how to handle it in code with GetFolderPath(). But is there similar functionality for controls properties and string settings/resources in the designer?

+1  A: 

The %APPDATA% refers to a special location in your source code folder (.i.e, %csprojectLocation%/AppData for sqlserver, %csprojectLocation% for MS Access). It is not the OS Application Data.

AFAIK there is no special variable that denotes the OS Application Data for dataset designers. So you have to manually set the connection string after you deploy it to your client computer. You can use an installer to do this though.

Ngu Soon Hui
Doh! Of course! Silly me. But how about ensuring a correctly defined connection string on the designer when the database is on a special folder like ApplicationData?
Krugar
Unfortunately, I don't think designer provides a special variable for you to connect to ApplicationData. So either you have to hack the generated designer class, or manually change the connection string after the deployment. That's the limitation I have lived with for 2~ 3 years.
Ngu Soon Hui
Hmm... seems then I will have to move it to the application settings file and then find a way to set it up correctly on the Setup project.
Krugar