DATABASE CONNECTION USING WEB CONFIG FILE - Day - 15/05/2003

 

Ø DATABASE CONNECTION USING WEB CONFIG FILE.

STEP 1:- open web config file

S2:- <configuration>

 

  <appSettings>

    <add key="mydb" value="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\college.mdf;Integrated Security=True" />

  </appSettings>

 

  <system.web>

    <compilation debug="false" targetFramework="4.6.1" />

    <httpRuntime targetFramework="4.6.1" />

  </system.web>

 

</configuration>

 

Ø How to connect web config to aspx page.

using System.Configuration;//aceess web config file

 

 

 

Ø Access app setting key value inside aspx page

Ø  string path = ConfigurationManager.AppSettings["mydb"];

Ø If version is of 2022 then webconfigurationManager

Comments

Popular posts from this blog

ViewState for state management

Store procedure Data Base handling (procedure_insert).

Database joining