Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Problem with user control and application/user settings

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GAZ - 22 Jul 2006 10:17 GMT
Hello all,

We have a bit of a problem with application settings and user control. In
short, we have developed a user control that should, as it happenes, get a
value stored in application settings of its host application. The app.config
of the host application looks like this:

 <appSettings>
   <add key="SQLConnectionString" value="some value" />
 </appSettings>

 <userSettings>
   <Test_Control_Library.My.MySettings>
     <setting name="UserSQL" serializeAs="String">
       <value>User</value>
     </setting>
   </Test_Control_Library.My.MySettings>
 </userSettings>

Now, our control can read the SQLConnectionString value from <appSettings>
by using:

   System.Configuration.ConfigurationSettings.AppSettings("SQLConnectionString")

However, what we really need to get is the value stored in the UserSQL
setting under <userSettings> and we haven't got a foggiest how to do it. The
reason behind using user settings is that the UserSQL value can change
during the course of work and hence all controls should reflect that change.

Any help would be greatly appreciated.

BR,

GAZ
GAZ - 24 Jul 2006 12:14 GMT
Got the solution:

In my application I added:

Dim config As System.Configuration.Configuration =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
config.AppSettings.Settings.Add("SQLConnectionString", "The-Conn-String")
config.Save(System.Configuration.ConfigurationSaveMode.Modified)
ConfigurationManager.RefreshSection("appSettings")

And in my control:

_SQLConnectionString =
System.Configuration.ConfigurationSettings.AppSettings("SQLConnectionString")

Somewhat awkward solution, could've been a bit simpler but there we go.

BR,

GAZ

> Hello all,
>
[quoted text clipped - 31 lines]
>
> GAZ

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.