My.Settings.Save() Not Saving

dukeofawesome

Member
Joined
Mar 22, 2006
Messages
23
Location
Australia
Programming Experience
Beginner
Hi,

Very much a newbie so please be paytient. I am using VB.Net 2013 for Windows Desktop.

I am tryng to save the connection string to the Access database from the user log on form to the My.Settings property. The actual setting is call NewCnnStr and is a User setting not an Application setting. My code is below:

VB.NET:
CnnStr = myFileDlog.FileName

My.Settings.NewCnnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & CnnStr
My.Settings.Upgrade()
My.Settings.Save()
My.Settings.Reload()

When I check the App.config file in the project root, no chnage. I compiled the project and ran it to see if it would save it in the user\<AppDataPath>, still no. I get no error and have stepped through the code and everything is as it should be from my understanding.

Any help would be most appreciated.

Thanks...

Duke
 
My.Settings.Upgrade()
My.Settings.Reload()
I think you have not read the documentation for those two calls, otherwise you wouldn't have included them in your code. Both will discard your runtime setting value.
My.Settings.Save()
Application framework will do this by default when application closes, so in normal cases you don't need that call either.
 
I think you have not read the documentation for those two calls, otherwise you wouldn't have included them in your code. Both will discard your runtime setting value.

Application framework will do this by default when application closes, so in normal cases you don't need that call either.

I am really confused as to which file the settings are supposed to be saved to. I orginally thought it was to App.config which clearly isn't the case. Where are the values saved to in the non-compiled version?

Thanks

Duke
 
Deployment storage and location is described here: Application Settings Architecture
Where are the values saved to in the non-compiled version?
In development project they are in MyProject/settings.settings file. Opening it is the same as opening Settings tab in project properties.
 
Hi John,

Thanks for your reply. I can not see a settings.settings file in my project folder.

I've got this working, but it's not how i evnisaged it working. The saved setting a placed in the C:\Users\<Username>\AppData\Local\<BusinessName>\<ProjectName>\<VersionNumber> folder. When the program is run it picks up the correct settings.

Does this sound right to you?

Thanks

Duke :subdued:
 
I can not see a settings.settings file in my project folder.
To see that you need to "Show All Files" in Solution Explorer, but you don't need to, the IDE interface to this is to open project properties and select the Settings tab.
Does this sound right to you?
Yes, it does.
 
Back
Top