call connectionstring from app/web configuration file..

Posted by Mittaikariss under C# category on | Points: 40 | Views : 2359
Web application and Window application........
<?xml version="1.0" encoding="utf-8" ?>
<add name="payroll"
connectionString="Data Source=SYSTEM3;Initial Catalog=payroll;Integrated Security=True"
providerName="System.Data.SqlClient" />

cn.ConnectionString = ConfigurationManager.ConnectionStrings["payroll"].ToString();;

window application
first add reference

add this reference to your project file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/System.configuration.dll

Invom Technology

Comments or Responses

Posted by: T.saravanan on: 9/18/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Kindly post your code inside the code tag.
Posted by: Ndebata on: 9/21/2011 Level:Starter | Status: [Member] | Points: 10

No need to convert it ToString() , it has a property called ConnectionString
ConfigurationManager.ConnectionStrings["payroll"].ConnectionString ;

Posted by: Mittaikariss on: 9/21/2011 Level:Bronze | Status: [Member] | Points: 10
hmm thanks bro....

Login to post response