Home All Groups Group Topic Archive Search About
Author
19 Aug 2006 12:51 PM
John
Hi

For my db app, I need to save the location of the db (really a windows path)
which normally only needs to be set at the first app start (I can check if
the setting is missing and ask user for a value). Occasionally (once in a
blue moon) I may need to change this setting in case db is moved to a
different server etc.

My question is what sort of mechanism can/should I use to store this
setting?

Thanks

Regards

Author
19 Aug 2006 2:41 PM
Tiago Salgado
A simple way to do that is using My.Settings ...

Go to Project > Properties ... > Settings and add a setting name (i.e.  =

db_path and set a Type for it)

Then, in your application, u can read it and write it using:

Read: Msgbox ( My.Settings.db_path.ToString )

Write: My.Settings.db_path =3D "anything"

-- =

Tiago Salgado
Blog: http://weblogs.pontonetpt.com/tiagosalgado


On Sat, 19 Aug 2006 13:51:24 +0100, John <John@nospam.infovis.co.uk> wro=
te:

Show quoteHide quote
> Hi
>
> For my db app, I need to save the location of the db (really a windows=
  =

> path)
> which normally only needs to be set at the first app start (I can chec=
k  =

> if
> the setting is missing and ask user for a value). Occasionally (once i=
n a
> blue moon) I may need to change this setting in case db is moved to a
> different server etc.
>
> My question is what sort of mechanism can/should I use to store this
> setting?
>
> Thanks
>
> Regards
>
>
Author
19 Aug 2006 2:48 PM
Herfried K. Wagner [MVP]
"Tiago Salgado" <tiagosalgado.develo***@gmail.com> schrieb:
>A simple way to do that is using My.Settings ...
>
>Go to Project > Properties ... > Settings and add a setting name (i.e.
>db_path and set a Type for it)
>
>Then, in your application, u can read it and write it using:
>
>Read: Msgbox ( My.Settings.db_path.ToString )
>
>Write: My.Settings.db_path = "anything"

ACK, but note that application-scoped settings cannot be changed using
'My.Settings'.  Typically the user running the application doesn't have
rights to manipulate the contents of the program files folder.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
19 Aug 2006 4:28 PM
Jeff Gaines
On 19/08/2006 John wrote:

>Hi
>
>For my db app, I need to save the location of the db (really a windows
>path) which normally only needs to be set at the first app start (I can
>check if the setting is missing and ask user for a value). Occasionally
>(once in a blue moon) I may need to change this setting in case db is
>moved to a different server etc.
>
>My question is what sort of mechanism can/should I use to store this
>setting?


If you have users without admin rights you're down to the registry or an
XML/ini file somewhere in the user's 'My Documents' folder.

--
Jeff Gaines