I’m going to demonstrate how to get connection string from App.config in C#.Net.

Example
App.config
<?xmlversion="1.0"encoding="utf-8" ?>
<configuration>
  <connectionStrings
    <addname="con1"connectionString="Server=abc\SQLEXPRESs;Database=Employee;Trusted_Connection=True"/>  
  </connectionStrings>
</configuration>
Form1.cs where we are going to use connection string of App.config
//namespace for sqlclient
using System.Data.SqlClient;
//to use connectionstring we have to use System.Configuration namespace
using System.Configuration; 
//fetching connectionstring from App.config
string strConnection= ConfigurationManager.ConnectionStrings["con1"].ConnectionString;
//creating newsqlconnection
 con= new SqlConnection(strConnection);
//opening connection
     con.Open();

 

  1. Utilize the Data Source Wizard to setup a wrote DataSet as DataSource for the report. do my homework This would enable you to utilize the Reporting Designer and all treats that accompany it. At that point supersede the ConnectionString gave by the DataSet the one indicated in your config document

Leave Comment