1.First open Visual Studio.net-> New WebSite->Asp.net WebSite and name it as sample
2.Open web.config and add the below code
<connectionstrings name="DBConnection" connectionstring="Data Source=.;Initial Catalog=DataBaseName;User ID=EnterUrUserName;Password=EnterUrPassword" providername="System.Data.SqlClient">
3.In the Default.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
protected void Page_Load()
{
SqlConnection con=new SqlConnection(ConfigurationManager.connectionStrings["DBConnection"].ConnectionString);
SqlCommand cmd=new SqlCommand();
con.Open();
cmd.commandText="inline queries/stored procedures";
cmd.Connection=con;
cmd.ExecuteNonQuery();
/* you can use
executescalar(); or SqlDataReader dr;dr=cmd.ExecuteReader();con.open();
while(dr.open())
{
//write code...
}
dr.close();
con.close();
*/
con.Close();
}
I hope the above code is useful for new begineers who are learning .NET.