We have two types of classes..
1) Factory 2) Singleton
1) Factory : You can create a multiple object of factory class.
2) Singleton : only one instance of the class is created ex..Mouse Pointer,window popup.
//singleton programme
using system;
public class singleton
{
private static singleton instance;
private singleton()
{
}
public static singleton instance
{
get
{
if(instance==null)
{
instance=new singleton();
}
return instance;
}
}
}
Thursday, March 18, 2010
Difference Between function and procedure in sqlserver
1)Function returns a value, but a procedure may return or may not return a value.
2)Function can take only input argument, but procedure may take both input and output parameters.
3)Function can be called inside the select statement but not the procedure
4)Function return 1 value only. Procedure can return multiple value.
5)Function are compiled and executed at runtime.Stored Procedure are stored in parsed and compiled format in the DataBase.
6)Function cannot affect the state of the database which means it cannot perform insert,update,delete and create operation on the database.
Stored procedure can affect the state of the database by using Insert,delete,update and create operation.
2)Function can take only input argument, but procedure may take both input and output parameters.
3)Function can be called inside the select statement but not the procedure
4)Function return 1 value only. Procedure can return multiple value.
5)Function are compiled and executed at runtime.Stored Procedure are stored in parsed and compiled format in the DataBase.
6)Function cannot affect the state of the database which means it cannot perform insert,update,delete and create operation on the database.
Stored procedure can affect the state of the database by using Insert,delete,update and create operation.
Number of user visit to your Website
//Take global.asax for make application level variable
void application_start(object sender,Eventargs e)
{
int count=convert.int32(application["hit"]);
count=0;
}
void session_start(object sender,eventargs e)
{
int count=convert.toint32(application["hit"]);
count=count+1;
application["hit"]=count;
}
//pageload
label1.text=convert.toint32(application["hit"]).tostrng();
void application_start(object sender,Eventargs e)
{
int count=convert.int32(application["hit"]);
count=0;
}
void session_start(object sender,eventargs e)
{
int count=convert.toint32(application["hit"]);
count=count+1;
application["hit"]=count;
}
//pageload
label1.text=convert.toint32(application["hit"]).tostrng();
Theme Asp.Net
//Take one dropdownlist insert the name of skin file (through collection or create the masters of themes)
Default
skinfile
Changetheme
BasicBlue
//page_preInit Event because theme work on preinit event
protected void page_PreInit(object Sender,EventArgs e)
{
string theme="";
if(page.request.form.count>0)
{
theme=page.request["Theme"].tostring();// Theme is the id of dropdown
if(theme=="Defaule")
{
theme="";
}
}
this.Theme=theme;
}
//page_preInit Event because theme work on preinit event
protected void page_PreInit(object Sender,EventArgs e)
{
string theme="";
if(page.request.form.count>0)
{
theme=page.request["Theme"].tostring();// Theme is the id of dropdown
if(theme=="Defaule")
{
theme="";
}
}
this.Theme=theme;
}
Asp.net page life cycle.
1)Init : When the page is instantiated.
2)Load : When the page is loaded into server memory.
3)Render : The brief moment before the page is displayed to the user as Html.
4)Unload : When page finish loading.
2)Load : When the page is loaded into server memory.
3)Render : The brief moment before the page is displayed to the user as Html.
4)Unload : When page finish loading.
Labels:
Asp.net page life cycle.
File Upload in Asp.net c#
//Take one file upload control and one button for save the file..
//button click
if(fileupload1.hasfile)
{
fileupload1.saveas(server.mappath(fileupload1.filename));
label1.text="file uploaded :" + fileupload1.filename;
}
else
{
label1.text="No file Upload";
}
//button click
if(fileupload1.hasfile)
{
fileupload1.saveas(server.mappath(fileupload1.filename));
label1.text="file uploaded :" + fileupload1.filename;
}
else
{
label1.text="No file Upload";
}
Labels:
File Upload in Asp.net c#
State Management
State Management is the process by which you maintain state and page information over multiple request for the same or different pages.
There are two types of state management..1) Client side
2) Server Side
Client Side : The store information on the client's computer by embedding the information into a webpage, a URL , or a Cookies ..The technique available to store the state information at the client end are listed down below..
a) View State: maintain the control state and retain the value of control.
b) Hidden field
c)Cookies: we have two types of cookies 1) persist: by default data has saved in persist cookies. and 2) NonPersist Cookies: By default data has lost in nonpersist cookies.
d) querystring: query string store value appended in the url that are visible to the user.maximum limit of query string is 255 character.
ServerSide State Management : Any data resides on the server and backand data base that's called in server side.
Two types of serverside state management: 1)Application State: Application state globaly for all user ..you can create global variable in Global.asax..inside the application.start event and session.start event.
2)Session Management : Its also globaly for a particular user...
There are two types of state management..1) Client side
2) Server Side
Client Side : The store information on the client's computer by embedding the information into a webpage, a URL , or a Cookies ..The technique available to store the state information at the client end are listed down below..
a) View State: maintain the control state and retain the value of control.
b) Hidden field
c)Cookies: we have two types of cookies 1) persist: by default data has saved in persist cookies. and 2) NonPersist Cookies: By default data has lost in nonpersist cookies.
d) querystring: query string store value appended in the url that are visible to the user.maximum limit of query string is 255 character.
ServerSide State Management : Any data resides on the server and backand data base that's called in server side.
Two types of serverside state management: 1)Application State: Application state globaly for all user ..you can create global variable in Global.asax..inside the application.start event and session.start event.
2)Session Management : Its also globaly for a particular user...
Labels:
State Management
Caching in Asp.Net
Caching : Caching is a feature of Asp.Net that improves the performance of web application by minimizing the usage of server resources to a greate extent.
Caching is a feature that store data in local memory ,allowing incoming request to be served from memory directly.
Benefits of caching : Faster page rendering.
: Minimizing of database hits.
: Minimizing of the consumption of server resources.
Asp.Net support three types of caching: 1)Page level caching(output caching)
2)Page fragment caching(partial page output
caching)
3)Programmatic or data caching .
Caching is a feature that store data in local memory ,allowing incoming request to be served from memory directly.
Benefits of caching : Faster page rendering.
: Minimizing of database hits.
: Minimizing of the consumption of server resources.
Asp.Net support three types of caching: 1)Page level caching(output caching)
2)Page fragment caching(partial page output
caching)
3)Programmatic or data caching .
Labels:
Caching in Asp.Net
Department Wise sum() of Salary
Select * from emp order by depart desc
compute sum(salary) by depart
compute sum(salary) by depart
Labels:
Department Wise sum() of Salary
Aalgorithm and FlowChart
Flowchart : A flowchart is a graphical representation of an algorithm..
Algorithm : An algorithm is just a detailed sequence of simple steps that are needed to solve a problem.
A formula or set of steps for solving a particular problem to be an algorithm..
Algorithm : An algorithm is just a detailed sequence of simple steps that are needed to solve a problem.
A formula or set of steps for solving a particular problem to be an algorithm..
Labels:
Aalgorithm and FlowChart
Value Type and Reference Type datatype
Value Type : All numeric data type,boolean type,char,Date,enumeration structure..
Reference Type :String,all array,class,delegate
Reference Type :String,all array,class,delegate
DDL,DML in sql server
DDL(Data Defination language): DDL are used to define the database structure or schema...example...Create Table, Alter Table,Drop,Truncate,Comment,Rename..
DML(Data Manipulation Language) : Statement are used to managing data within schema object.. example....Select,Insert,Delete,Update,Merge,Lock data.
DML(Data Manipulation Language) : Statement are used to managing data within schema object.. example....Select,Insert,Delete,Update,Merge,Lock data.
Labels:
DDL,
DML in sql server
Subscribe to:
Posts (Atom)