How To Ideas | How To Articles | How To Tutorials


0

How To Read Connection String Value From Web.Config File


You have already written Connection String in Web.Config file of your Web Application, Now you want to retrieve its value in code, So that you can connect to your Database. In this article I will show you how can you do this.

Instructions:
image

  1. Connection String From AppSettings
    If you have stored Connection String value in AppSettings then use this following code to get its value from Web.Config file in your code.
    string connectionString = System.Configuration.ConfigurationManager.AppSettings["conn"].ToString();
  2. Connection String From ConnectionStrings
    If you have stored Connection String value in ConnectionStrings tag in Web.Config then use this following code to get its value from Web.Config file in your code.
    string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString();

Incoming search terms:

  • facebook punjabi configuration (1)
  • recuperation connectionstring web config (1)
Filed in: ASP.NET Tags: , , , , , , , , , , , , , ,

Leave a Reply

Submit Comment



© 9184 How To Ideas. All rights reserved.
Proudly designed by Theme Junkie.