When I add two connection strings in the web.config, an error appears that tells me I can't add two connection strings in the web.config.
I want the upper job because I have 2 databases and I want transfer data from another to the other one.
Would you please show me a way for doing that?
To edit a connection string stored in application settingsLocate the connection you want to edit and select the text in the Value field. Edit the connection string in the Value field, or click the ellipsis (...) button in the Value field to edit your connection with the Connection Properties dialog box.
Declaring connectionStrings in web. config file: <connectionStrings> <add name="dbconnection" connectionString="Data Source=Soumalya;Integrated Security=true;Initial Catalog=MySampleDB" providerName="System.
The connection strings are mostly stored in web. config. It means that connection specific information such as database name, username, and password are stored as a clear text in a file. This is definitely a security concern for your Production servers.
Simply put those strings in your web.config:
<connectionStrings>
<add name="CS1"
connectionString="SOME CONNECTION STRING"
providerName="System.Data.SqlClient" />
<add name="CS2"
connectionString="SOME OTHER STRING"
providerName="System.Data.SqlClient" />
</connectionStrings>
And then pick the one you wish in your code:
string cs = ConfigurationManager.ConnectionStrings["CS2"].ConnectionString;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With