<connectionstring>
<add name="DBSource" connectionString="Database=perfact;Server=Amrit;UID=sa;PWD=amrit@123" providerName="System.Data.SqlClient"/>
write the above code in web.config file
add the Code In code behined file e.g con1.aspx
using System.text;
using System.Configuration;
using Mycon;
protect void page_load(object sender, eventArgs e)
{
// to know that connection name DBSource exits or not
lblcon.text=configurationManager.connectionstring["DBSource"].connectionstring;
}
// Make a class in app_code folder
Name it myConnection
and
make a namespace
write the folling code
using System.data;
using System.text;
using System.Configuration.
namespace Mycon // Add this namespace in codebehind file con1.aspx.cs
{
public partial myConnection: classname
{
//Constrotor logic
}
// Make a connection string
public static string connectionstring=configurationManager.connectionstring["DBSource"].connectionstring.
}
//save the file never forgert to add this namespace Mycon in con1.aspx.cs code behind file