Link to home
Start Free TrialLog in
Avatar of zipnotic
zipnoticFlag for United States of America

asked on

My.Settings Won't actually save

Hello Experts,

I'm putting together a small application that uses a few user settings in my.settings.  I am saving the changes with my.settings.save() and as long as the applicaiton is open and stays running the settings look to be changed in the properties.  WHen I close the app and reopen it the settings are back to their original values.  I'm guessing the app is saving to the wrong file.  I started programming it on a desktop then took it on the road by copying the folder to my laptop.  Is there a place where I need to tell VS 2010 where to save the config file?  The App.Config file in the project folder looks to be the one NOT updating properly.

THanks for your thoughts
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Can you show some code?
Avatar of zipnotic

ASKER

Getting and saving:    

       If ds.Tables("Events").Rows.Count > 0 Then
                My.Settings.EventPK = ds.Tables("Events").Compute("Max(Event_PK)", Nothing)
                Me.txtLastEventPK.Text = My.Settings.EventPK
                My.Settings.DateUpdated = Now()
                Me.txtLastDate.Text = Now().ToString
                LogIt("Updated MAX PK to " & Me.txtLastEventPK.Text)
            End If
            My.Settings.Save()

Using:

sql = "SELECT * FROM [v_Event] WHERE [Event_PK] > '" & My.Settings.EventPK & "'"
Are you getting the right results in Me.txtLastEventPK.Text and Me.txtLastDate.Text ?
Yes, as long as the program stays open.  AT each update it is the correct Number.  After I close and reopen the EventPK reverts to the original setting when it should stay at the last/higher number.  Ultimately I am trying to track only the new records added to the table.
I believe I have solved the issue.  Under PROPERTIES for the SETTINGS.VB file I changed to COPY ALWAYS instead of do not copy.  This forces the compiler to add and update the Settings when debugging.  Unfortunately it does NOT update the original settings file...Any idea on how to update both as I develop the program?

AND ensure that the settings get updated when deployed to a different computer?
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is there anyway to use a universal 'my.settings' not dependent on the the user logged on, or am I stuck managing my own XML file if I want to go that route?
The standard My.Settings has been created to help in the most common scenario.

If you want to do otherwise, you have to either implement your own system, or inherits from System.Configuration.ApplicationSettingsBase to modify the way the default configuration system is working.
Who could have known?  Thanks.