Search code examples
vb.netmy.settings

why settings not save after close open application , using vb.net


hi this my code to change property from application setting (connection string)

i can't use my.settings.ConnectionString1= "some connectionstring" because it read only so i use my.settings.item()= ""

 dim x= textbox1.text  ' //  like 127.0.0.1
 My.Settings.Item("ConnectionString1") = "server=" & x & ";user  id=root;password=root;port=3306;database=db1;charset=utf8;"
 My.Settings.Save()
 msgbox(my.settings.ConnectionString1)   ' here change happen 
 Me.Close()

after close and open it the i found the value not change


Solution

  • i was solved it by declare new variable in "application setting" to store connection string every time changed, and copy it value to the main connection string variable every time loading form