zipnotic
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
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
Can you show some code?
ASKER
Getting and saving:
If ds.Tables("Events").Rows.C ount > 0 Then
My.Settings.EventPK = ds.Tables("Events").Comput e("Max(Eve nt_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 & "'"
If ds.Tables("Events").Rows.C
My.Settings.EventPK = ds.Tables("Events").Comput
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 ?
ASKER
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.
ASKER
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?
AND ensure that the settings get updated when deployed to a different computer?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.Appli cationSett ingsBase to modify the way the default configuration system is working.
If you want to do otherwise, you have to either implement your own system, or inherits from System.Configuration.Appli
ASKER
Who could have known? Thanks.