Live Chat Icon For mobile
Live Chat Icon

What is the best place to store Database connection string?

Platform: ASP.NET| Category: Config files

In Web.Config, you would add a key to the AppSettings Section:


<appSettings> 
<add key='MyDBConnection' value='server=<ServerName>;uid=<Username>;pwd=;database=<DBName>' />
</appSettings>

Example :


<add key='ConnectionString' value= 'Server=localhost;uid=sa;pwd=;database=northwind' />

Then, in your ASP.Net application – just refer to it like this:


Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings('ConnectionString'))

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.