Pointing a ConnectionString to a special folder via Visual Studio Designer

667 views Asked by At

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

There are 1 answers

3
Graviton On BEST ANSWER

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.