If you change the the database connection-string user/id during the run time, then one solution for you could be to place a "PlaceHolder" inside the config file,
Data Source=MYSERVER\MYINSTANCE;Initial Catalog=MYDB;User ID=%UID%;Password=%PWD%;
When you fetch connection string in your code, replace %UID%
and %PWD%
with your userid/password.
As a side note, usually, seldom we require the change in uid/pwd during runtime; and that directly inside the config file. Even when needed, its one-time activity, for instance, during installation or everytime user changes the database explicitly, etc. So if you are coming from there, then you can fetch the value during installation and push it inside you config file.