my.Settings.connectionstrings are application scope and therefore readonly!
What is that about, how can something fundamental like the connection string not be able to be changed at runtime. After much blood sweat and tears looking into this there is a work around. It's a bit of a fudge but it works:
To quote RadicalSoftwareSolutions
from this thread
Hi All
I have found a workaround to this but I'm still looking for a better solution (i.e changing the app.config files)
The solution I have used involves changing the settings.desogner.vb code which is created by the dataset design tool. The only reason my.settings.
are read only is that the designer only creates a "Get" property for them, its a 2 line change to add the "Set" property (since all we're doing is storing a string value there!). I then set the value to what I want in the settings.vb.settingsloaded function.
Ok it's not perfect as the settings.designer.vb gets re-written every time the designer is changed but you'll know if that's happened as the connectionstring will become readonly again and your code won't compile.
Obviously you'll have to do this for each connectionstring if you have more than one and don't forget to remove the "readonly" value from the property command
Ian
Thanks Ian, I thought I was going mad there for a while...
To quote RadicalSoftwareSolutions
from this thread
Hi All
I have found a workaround to this but I'm still looking for a better solution (i.e changing the app.config files)
The solution I have used involves changing the settings.desogner.vb code which is created by the dataset design tool. The only reason my.settings.
Ok it's not perfect as the settings.designer.vb gets re-written every time the designer is changed but you'll know if that's happened as the connectionstring will become readonly again and your code won't compile.
Obviously you'll have to do this for each connectionstring if you have more than one and don't forget to remove the "readonly" value from the property command
Ian
Thanks Ian, I thought I was going mad there for a while...
