Parag’s Den

Dedicated to my adored friends…..

Asp.Net (The best way to store the connection string.)

Posted by paragdongre on November 6, 2007


I am pretty sure that, everyone knows about the web.config file, which holds the application wide settings. Web.config file can also be used to hold the connection string info. Let us see how we can do this.

All you need to do is to place the following file lines in your web.config file.

<configuration>
     <appSettings>
          <add key=”DSN” value=”Server=moon;database=Store;Trusted_Connection=yes” />
     </appSettings>
</configuration>

To retrieve the key called DSN from your ASP .NET page, you need to have the following statement.

Dim dsn As String = ConfigurationSettings.AppSettings(“DSN”)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: