Breaking News

LightBlog

Sunday, 6 March 2016

Get (Read) Connectionstring from App.Config File in C#



Introduction:

Here I will explain how to read or get connectionstring from app.config file in 
c#. By using System.Configuration reference we can read or get connectionstring from app.config file in windows or console application in c#.



<connectionStrings>
<add name="dbconnection" connectionString="DataSource=KaushikDhameliya;Initial Catalog=Kaushik;Integrated Security=true" providerName="System.Data.SqlClient" />
</connectionStrings>

string admin= ConfigurationManager.ConnectionStrings["admin"].ConnectionString;