i want to change a connection string to read from web.Config instead of hard coded connection string. this is the connection string that i want to change
Loading
i want to change a connection string to read from web.Config instead of hard coded connection string. this is the connection string that i want to change
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prasad RaveendranPosted Jul 7, 2023, 1:29 AM
I'm wondering whether you have web.config transformation. if yes, you can update your connection string there. Based on the environment, you can update the connection string in each web.config transformation
yolula SISILANAPosted Jul 5, 2023, 7:37 AM
in the web.config file the connection string already exists. i want to link it so that it reads from web.config instead of hard coded connection string
Deepak RawatPosted Jul 5, 2023, 7:01 AM
Open the web.config file of your project.
Locate the
section within theelement.Replace the existing connection string entry with the following code:
Save the web.config file.
In your code, you can now retrieve the connection string using the
ConfigurationManager.ConnectionStringsproperty. Here's an example of how you can modify your code:yolula SISILANAPosted Jul 5, 2023, 6:54 AM
no. how do i change it
Ramesh PalanivelPosted Jul 5, 2023, 6:48 AM
HI Yolula,
Are you getting any error ?