Friday, March 25, 2022

Connection string in ASP.NET and App setting key and value

 web.config connection string

<configuration>

<connectionStrings>

<add name="connectionString" connectionString="data source =.\sqlexpress;initial catalog=aggregate;user id=sa1;password=sa;" />

or

<add name="CmsConn" connectionString="Data Source=.;Initial Catalog=PMSNoChange;User Id=sa;Password=19102022" />


or

<add name="CmsConn" connectionString="Data Source=10.15.251.256;Initial Catalog=PMSNoChange;User Id=sa;Password=19102022" /> (IP address of server)

</connectionStrings>

</configuration>


or 


web.config connection string

<configuration>

<connectionStrings>

<add name="connectionString" connectionString="initial catalog=aggregate;user=sa1;password=sa;data source=." />

</connectionStrings>

</configuration>


<appSettings>

    <add key="ConnectionString" value="Server=DESKTOP-EUCFT2Q\SQLDEV; Database=ESDM_NIELIT_NEW; UID=sa; PWD=25032022;Min Pool Size=20; Max Pool Size=200"/>

    <!--<add key="ConnectionString" value="Server=10.249.164.100; Database=ESDM_NIELIT_NEW; UID=esdm-skill; PWD=Esdm@321;Min Pool Size=20; Max Pool Size=200" />-->

    <add key="nsdlgateway" value="http://192.168.1.70/ESDM/PaymentSucessful.aspx" />

    <add key="MerchantId" value=" MYSITE " />

</appSettings>




using System;

using System.Collections.Generic;

using System.Text;


//Add reference to System.Web if not yet referenced

using System.Web;

using System.Web.Configuration;


namespace CompanyName.Connection

{

    public abstract class Configuration

    {

        public static String ConnectionString

        {

            get

            {

                return WebConfigurationManager.AppSettings["ConnectionString"];

            }

        }


       

    }

}


No comments:

Post a Comment