Without adding a connection string how can you modify it. Also i did it to show users how to add a new connection string and also how to update it.
My code checks whether connection string exists. If it does it is updated else a new is created
What you are trying to do is incorrect. If you want to connecto to different database have multiple connection strings in web.config. Why you want to update the same?
This will make your application crash as web.config is meant for reading and not for writing