Posts

Showing posts from November, 2016

What is the best place to store Database connection string?

In Web.Config, you would add a key to the AppSettings Section: <appSettings> <add key="MyConnection" value="server=<ServerName>; uid=<Username>; pwd=<Password>; 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))