-2

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

  • 1
    Make sure that setting is `User` based in the settings.... – Trevor Feb 13 '19 at 20:41
  • Scop = application , not user – abbas mohammed Feb 13 '19 at 22:29
  • And if you change it, what happens? – Trevor Feb 13 '19 at 22:30
  • 1
    Settings with Application scope are read-only via `My.Settings`. You can change them via the configuration system but not all users will necessarily have permission to write to the primary config file. Settings with User scope are stored under the user's personal folder, so are guaranteed to be writeable. It you want to edit Application-scoped settings, check [this](http://www.vbforums.com/showthread.php?532768) out. You can just ignore the encryption part. – jmcilhinney Feb 13 '19 at 23:45

2 Answers2

0

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

-1

try to use:

My.Settings.ConnectionString1 = "server=" & x & ";user  id=root;password=root;port=3306;database=db1;charset=utf8;"
My.Settings.Save()
  • i solved it by declare new variable in " application setting " to store connection string every time changed , and copy it vale to the main connection string variable every time loading form – abbas mohammed Mar 05 '19 at 16:05
  • ConnectionString 1 declared inside application scope which is not supporting initial by equation – abbas mohammed Mar 05 '19 at 16:09