1)Application pool is a grouping of URLs that is routed to one or more worker processes.
2)An application pool is a group of one or more URLs of different Web applications and Web sites. Any Web directory or virtual directory can be assigned to an application pool.
Every application within an application pool shares the same worker process executable, W3wp.exe, the worker process that services one application pool is separated from the worker
process that services another [Like starting MS Word and opening many word documents]. Each separate worker process provides a process boundary so that when an application is assigned to one application pool, problems in other application pools do not affect the application. This
ensures that if a worker process fails, it does not affect the applications running in other application pools. [i.e] for Eg., If word document is having issue it should not
logically affect your Excel Sheet isn’t it. application domain is a mechanism (similar to a process in an operating system) used to isolate executed software applications from one another so that they do not affect each other. [i.e] opening of MS WORD doesn’t affect MS EXCEL
you can open and close both the applications any time since there is no dependency between the applications. Each application domain has its own virtual address space which scopes the resources for the application domain using that address space.
Thursday, February 24, 2011
Wednesday, February 23, 2011
sql server funcation Return Table (User Defined Function)
create function fun(@id int)
returns table
as
return (select name from students where id=@id)
//How to use in sql server
select * from master.dbo.fun(1);
////how to use in asp.net
con.open();
SqlCommand cmd = new SqlCommand("select name from schools.dbo.fun(3)", con);
SqlDataReader dr2 = cmd.ExecuteReader();
if (dr2.HasRows)
{
while (dr2.Read())
{
string s= dr2.GetString(0);
}
}
con.close();
///another Function return string
CREATE FUNCTION GetFullName()
RETURNS varchar(100)
AS
BEGIN
RETURN 'Doe, John'
END
//how to use function in sql server
PRINT Schools.dbo.GetFullName();
returns table
as
return (select name from students where id=@id)
//How to use in sql server
select * from master.dbo.fun(1);
////how to use in asp.net
con.open();
SqlCommand cmd = new SqlCommand("select name from schools.dbo.fun(3)", con);
SqlDataReader dr2 = cmd.ExecuteReader();
if (dr2.HasRows)
{
while (dr2.Read())
{
string s= dr2.GetString(0);
}
}
con.close();
///another Function return string
CREATE FUNCTION GetFullName()
RETURNS varchar(100)
AS
BEGIN
RETURN 'Doe, John'
END
//how to use function in sql server
PRINT Schools.dbo.GetFullName();
Ajax Help for Designing any pages(Source Code)
www.dynamicdrive.com/
//download ajax .dll(AjaxControlToolkit.dll) and Add it into your project....
after that add the @Register directive: @Register Directive use for informs the compiler of any custom server control add to the page..
%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
after that use the Reference Link " www.dynamicdrive.com/ "
//download ajax .dll(AjaxControlToolkit.dll) and Add it into your project....
after that add the @Register directive: @Register Directive use for informs the compiler of any custom server control add to the page..
%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
after that use the Reference Link " www.dynamicdrive.com/ "
HTML REPORT and Print the Html Report
//Take one Input Button for Print
input type="button" id="btnPrint" runat="server" value ="Print" onclick ="PrintReport();"/>
//Make one method for print
script type="text/javascript" language="javascript" >
function PrintReport() {
var bt = document.getElementById("btnPrint").style.display='block';
window.print()
}
/script>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ con.open();
SqlCommand cmd = new SqlCommand("select * from students", con);
SqlDataReader oDr = cmd.ExecuteReader();
if (oDr.HasRows)
{
StringBuilder sb = new StringBuilder();
sb.Append("");
sb.Append("
");
Response.Write(sb);
con.close();
}
}
}
input type="button" id="btnPrint" runat="server" value ="Print" onclick ="PrintReport();"/>
//Make one method for print
script type="text/javascript" language="javascript" >
function PrintReport() {
var bt = document.getElementById("btnPrint").style.display='block';
window.print()
}
/script>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ con.open();
SqlCommand cmd = new SqlCommand("select * from students", con);
SqlDataReader oDr = cmd.ExecuteReader();
if (oDr.HasRows)
{
StringBuilder sb = new StringBuilder();
sb.Append("
| Financial Report | ||
|---|---|---|
| "); sb.Append("id".ToString()); sb.Append(" | ");
sb.Append(""); sb.Append("Name".ToString()); sb.Append(" | ");
sb.Append(""); sb.Append("Roll".ToString()); // finish the rest of the row sb.Append(" |
| "); sb.Append(oDr["id"].ToString()); sb.Append(" | ");
sb.Append(""); sb.Append(oDr["Name"].ToString()); sb.Append(" | ");
sb.Append(""); sb.Append(oDr["Roll"].ToString()); // finish the rest of the row sb.Append(" |
Response.Write(sb);
con.close();
}
}
}
Three Tier Insert and Retrieve Data(Using Singleton for SqlConnection only)
Application layer(PL) :- is the form where we design using the controls like textbox, labels, command buttons etc.
Business layer(BAL) :- is the class where we write the functions which get the data from the application layer and passes through the data access layer.BAL contains business logic, validations or calculations related with the data, if needed.
Data layer(DAL) :- is also the class which gets the data from the business layer and sends it to the database or gets the data from the database and sends it to the business layer.
Property layer(BE) :- is the sub layer of the business layer in which we make the properties to sent or get the values from the application layer. These properties help to sustain the value in a object so that we can get these values till the object destroy.
////// SQL HELPER CLASS(Inside the DAL Make sql Helper class) for connection string........
public class sqlHelper
{
private static SqlConnection connection = null;
public static SqlConnection conn
{
get
{
if (connection == null)
{
connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolsConnectionString"].ConnectionString);
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
return connection;
}
}
public static void closeconn(SqlConnection connection)
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();
}
}
}
///////// DAL(Data Access Layer) CLASS LIBRARY..............
Using BE; //ADD REFERENCE OF BE
public class DAL
{
public int InsertDal(BE.BE obBe)
{
try
{
SqlCommand cmd = new SqlCommand("Insert_Student", sqlHelper.conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("Name", obBe.Name);
cmd.Parameters.AddWithValue("Roll", obBe.Roll);
return cmd.ExecuteNonQuery();
}
catch
{
sqlHelper.closeconn(sqlHelper.conn);
throw;
}
finally
{
sqlHelper.closeconn(sqlHelper.conn);
}
}
public DataSet BindDal()
{
try
{
SqlCommand cmd = new SqlCommand("Bind", sqlHelper.conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
return ds;
}
catch
{
sqlHelper.closeconn(sqlHelper.conn);
throw;
}
finally
{
sqlHelper.closeconn(sqlHelper.conn);
}
}
}
/////////// BAL(Business Access Layer) CLASS LIBRARY....................
Using DAL;
Using BE;
public class BAL
{
DAL.DAL obDal = new DAL.DAL();
public int InsertBal(BE.BE obBe)
{
try
{
return obDal.InsertDal(obBe);
}
catch { throw; }
}
public DataSet BindBal()
{
try
{
return obDal.BindDal();
}
catch { throw; }
}
}
////// BE(Business Entity) CLASS LIBRARY.............(Property)
public class BE
{
private int _Id;
private string _Name = string.Empty;
private int _roll;
public int Id
{
get { return _Id; }
set { _Id = value; }
}
public string Name
{
get { return _Name; }
set { _Name = value; }
}
public int Roll
{
get { return _roll; }
set { _roll = value; }
}
}
/////////// PL(Persentation Layer).aspx Page
using BE;
using BAL;
BAL.BAL OBbAL = new BAL.BAL ();
BE.BE obBe = new BE.BE();
//Retrieve the value
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataSource = OBbAL.BindBal();
GridView1.DataBind();
}
}
//Insert the value
protected void btnInsert_Click(object sender, EventArgs e)
{
obBe.Name =TextBox1.Text.Trim().Replace(",","''");
obBe.Roll =Convert.ToInt32(TextBox2.Text.Trim().Replace(",","''"));
OBbAL.InsertBal(obBe);
TextBox1.Text = "";
TextBox2.Text = "";
}
Business layer(BAL) :- is the class where we write the functions which get the data from the application layer and passes through the data access layer.BAL contains business logic, validations or calculations related with the data, if needed.
Data layer(DAL) :- is also the class which gets the data from the business layer and sends it to the database or gets the data from the database and sends it to the business layer.
Property layer(BE) :- is the sub layer of the business layer in which we make the properties to sent or get the values from the application layer. These properties help to sustain the value in a object so that we can get these values till the object destroy.
////// SQL HELPER CLASS(Inside the DAL Make sql Helper class) for connection string........
public class sqlHelper
{
private static SqlConnection connection = null;
public static SqlConnection conn
{
get
{
if (connection == null)
{
connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolsConnectionString"].ConnectionString);
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
return connection;
}
}
public static void closeconn(SqlConnection connection)
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();
}
}
}
///////// DAL(Data Access Layer) CLASS LIBRARY..............
Using BE; //ADD REFERENCE OF BE
public class DAL
{
public int InsertDal(BE.BE obBe)
{
try
{
SqlCommand cmd = new SqlCommand("Insert_Student", sqlHelper.conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("Name", obBe.Name);
cmd.Parameters.AddWithValue("Roll", obBe.Roll);
return cmd.ExecuteNonQuery();
}
catch
{
sqlHelper.closeconn(sqlHelper.conn);
throw;
}
finally
{
sqlHelper.closeconn(sqlHelper.conn);
}
}
public DataSet BindDal()
{
try
{
SqlCommand cmd = new SqlCommand("Bind", sqlHelper.conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
return ds;
}
catch
{
sqlHelper.closeconn(sqlHelper.conn);
throw;
}
finally
{
sqlHelper.closeconn(sqlHelper.conn);
}
}
}
/////////// BAL(Business Access Layer) CLASS LIBRARY....................
Using DAL;
Using BE;
public class BAL
{
DAL.DAL obDal = new DAL.DAL();
public int InsertBal(BE.BE obBe)
{
try
{
return obDal.InsertDal(obBe);
}
catch { throw; }
}
public DataSet BindBal()
{
try
{
return obDal.BindDal();
}
catch { throw; }
}
}
////// BE(Business Entity) CLASS LIBRARY.............(Property)
public class BE
{
private int _Id;
private string _Name = string.Empty;
private int _roll;
public int Id
{
get { return _Id; }
set { _Id = value; }
}
public string Name
{
get { return _Name; }
set { _Name = value; }
}
public int Roll
{
get { return _roll; }
set { _roll = value; }
}
}
/////////// PL(Persentation Layer).aspx Page
using BE;
using BAL;
BAL.BAL OBbAL = new BAL.BAL ();
BE.BE obBe = new BE.BE();
//Retrieve the value
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataSource = OBbAL.BindBal();
GridView1.DataBind();
}
}
//Insert the value
protected void btnInsert_Click(object sender, EventArgs e)
{
obBe.Name =TextBox1.Text.Trim().Replace(",","''");
obBe.Roll =Convert.ToInt32(TextBox2.Text.Trim().Replace(",","''"));
OBbAL.InsertBal(obBe);
TextBox1.Text = "";
TextBox2.Text = "";
}
Tuesday, February 22, 2011
Indexer in c#
//Indexer in c#
C# introduces a new concept known as Indexers which are used for treating an object as an array. The indexers are usually known as smart arrays in C# community.
Defining a C# indexer is much like defining properties. We can say that an indexer is a member that enables an object to be indexed in the same way as an array.
Indexer is a collection of SET and GET methods.
Indexer name must be "this".
One class can have only one indexer.
Indexer Concept is object act as an array.
Indexers in C# must have at least one parameter.
Else the compiler will generate a compilation error.
indexers are never static in C#.
Benefits:-
Indexers always need an object reference to assign or retreive data from arrays or collections.
The following is syntax
this [argument list]
{
get
{
// Get codes goes here
}
set
{
// Set codes goes here
}
}
//Example
class IndexerClass
{
private string[] names = new string[10];
public string this[int i]
{
get
{
return names[i];
}
set
{
names[i] = value;
}
}
}
static void Main(string[] args)
{
IndexerClass text = new IndexerClass();
text[0] = "subhash";
text[1] = "subhash1";
text[2] = "subhash2";
for (int i = 0; i < 10; i++)
{
Console.WriteLine(text[i]);
}
Console.ReadKey();
}
C# introduces a new concept known as Indexers which are used for treating an object as an array. The indexers are usually known as smart arrays in C# community.
Defining a C# indexer is much like defining properties. We can say that an indexer is a member that enables an object to be indexed in the same way as an array.
Indexer is a collection of SET and GET methods.
Indexer name must be "this".
One class can have only one indexer.
Indexer Concept is object act as an array.
Indexers in C# must have at least one parameter.
Else the compiler will generate a compilation error.
indexers are never static in C#.
Benefits:-
Indexers always need an object reference to assign or retreive data from arrays or collections.
The following is syntax
{
get
{
// Get codes goes here
}
set
{
// Set codes goes here
}
}
//Example
class IndexerClass
{
private string[] names = new string[10];
public string this[int i]
{
get
{
return names[i];
}
set
{
names[i] = value;
}
}
}
static void Main(string[] args)
{
IndexerClass text = new IndexerClass();
text[0] = "subhash";
text[1] = "subhash1";
text[2] = "subhash2";
for (int i = 0; i < 10; i++)
{
Console.WriteLine(text[i]);
}
Console.ReadKey();
}
Subscribe to:
Posts (Atom)