how to get connectionstring from app config in c#
  • how can i use app.config connectionstring in .cs file in c#
  • 1 Comment sorted by
  • Vote Up0Vote Down ithackerithacker
    117.50 Karma Accepted Answer
    hi @coder use below code.

    app.config code

    <?xml version="1.0" encoding="utf-8" ?>
            <add name="dbAccountsConnectionString"
                connectionString="Data Source=.\sqlExpress;Initial Catalog=dbAccounts;Integrated Security=True"
                providerName="System.Data.SqlClient" />

    form1.cs code

    string conStr = System.Configuration.ConfigurationManager.ConnectionStrings["dbAccountsConnectionString"].ConnectionString;

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook


Popular Posts of the Week

    Optimum Creative