Wednesday, August 29, 2012

Difference between ViewState and SessionState


S.NoViewStateSessionState
1
View state is maintained in page level only.
Session state is maintained in session level.
2
View state of one page is not visible in another page.i.e., when user requests another page previous page data will be no longer available.
Session state value is available in all pages within a user session.i.e., The data will be no longer available if user close the browser or session timeout occurs.
3
View state information stored in client only.
Session state information stored in server.
4
View state persist the values of particular page in the client (browser) when post back operation done.
Session state persist the data of particular user in the server. This data available till user close the browser or session time completes.
5
View state used to persist page-instance-specific data.
Session state used to persist the user-specific data on the server side.

Difference between Session and Cookies


S.NoSession StateCookies
1
Session can store any type of data because the value is of datatype of "object"
Cookies can store only "string" datatype
2
These are stored at Server side
They are stored at Client side
3
Session are secured because it is stored in binary format/encrypted form and it gets decrypted at server 
Cookie is non-secure since stored in text format at client side
4
Session is independent for every client i.e individual for every client
Cookies may or may not be individual for every client
5
There is no limitation on size or number of sessions to be used in an application
Due to cookies network traffic will increase.Size of cookie is limited to 40 and number of cookies to be used is restricted to 20.
6
For all conditions/situations we can use sessions
Only in few situations we can use cookies because of no security
7
We cannot disable the sessions.Sessions can be used without cookies also(by disabling cookies)
We can disable cookies
8
The disadvantage of session is that it is a burden/overhead on server
Since the value is string there is no security
9
Sessions are called as Non-Persistent cookies because its life time can be set manually
We have persistent and non-persistent cookies

Difference between Gridview,Datalist and Repeater


  • Gridview - Limited in design, works like an html table. More in built functionality like edit/update, page, sort. Lots of overhead.
  • DataGrid - Old version of the Gridview. A gridview is a super datagrid.
  • Datalist - more customisable version of the Gridview. Also has some overhead. More manual work as you have to design it yourself.
  • ListView - the new Datalist : Almost a hybrid of the datalist and gridview where you can use paging and build in Gridview like functionality, but have the freedom of design. One of the new controls in this family
  • Repeater - Very light weight. No built in functionality like Headers, Footers. Has the least overhead.
    Features of a GridView 
    •Displays data as a table
    •Control over
     –Alternate item
     –Header
     –Footer
     –Colors, font, borders, etc.
     –Paging
    •Updateable
    •Item as row
    Features of Repeater
    •List format
    •No default output
    •More control
    •More complexity
    •Item as row
    •Not updateable
    
    Features of DataList
    •Directional rendering
    •Good for columns
    •Item as cell
    •Alternate item
    •Updateable
    
     Repeater :
        It contains  Header Template, Item template , alternate
    Item template and footer template . it can't support
    Selection, editing, sorting and paging. this is read only
    and fast.
    
    Datalist :
     
       It contains Header Template, Item template , alternate
    Item template , Edit itm template and footer template . it
    can't support  sorting and paging but  support selection and
    editing
    
    DataGrid(or GridView) :
    
    It contains Header Template, Item template , alternate Item
    template , Edit itm template and footer template . it can
    support selection, editing , sorting and paging . Mostly
    every developer caught used this control  .

Monday, August 27, 2012

Difference between DataTable.Copy and DataTable.Clone


Both the methods DataTable.Clone and DataTable.Copyare are used to make copies of existing datatables, the difference is

DataTable.Clone() - Copies only the structure of the source table with the constraints, the data is not copied from the source table.

DataTable.Copy() - Copies the structure and data from the source table.


Example: 
DataTable.Clone()
DataTable dt;
dt= sourceTable.Clone();

Here, the targetTable is created with only the structure of the sourceTable
targetTable.Rows.Count() returns 0.

Example: DataTable.Copy()
DataTable dt;
dt= sourceTable.Copy();

Tuesday, August 21, 2012

Difference Between TRUNCATE & DELETE

TRUNCATE
DELETE
faster and uses fewer system and transaction log resources than DELETE.
 Slower than truncate because, it maintain logs for every record.
removes the data by deallocating the data pages used to store the tables data, and only the page deallocations are recorded in the transaction log.
removes  rows one at a time and records an entry in the transaction log for each deleted row.
removes all rows from a table, but the table structure and its columns, constraints, indexes and so on remain. The counter used by an identity for new rows is reset to the seed for the column.
If you want to retain the identity counter, use DELETE instead. If you want to remove table definition and its data, use the DROP TABLE statement.
You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint;
use DELETE statement without a WHERE clause
Because TRUNCATE TABLE is not logged, it cannot activate a trigger.
Activates Trigger
No Roll back
Can Rollback
DDL Command
DML Command

Difference between EXE and DLL

- EXE stands for Extensible Execute File and DLL stands for Dynamic Link Library. It is also called assembly in Dot Net.

- EXE gives direct output, it needs a resource and DLL does not give direct output, it always execute with any software and provide resource to that software.

- EXE is use by End User like-Client but DLL can not use by End User.

- An ActiveX Dll runs is an in process server running in the same memory space as the client process and an ActiveX Exe is an out of process server which runs in it's own separate memory space.

- EXE runs independently, whereas DLL runs within an EXE. DLL is an in-process file and EXE is an out-process file.

- A DLL would share the same process and memory space of the calling application while an EXE creates its separate process and memory space.

- And another difference is that EXEs are executable programs while DLLs are libraries loaded into a process and contain some sort of useful functionality like security, database access or something.

- EXE is mainly executable files which execute when user run the programs or click on them whereas DLL contains the function and procedure which link dynamically when needs them.

Difference between WCF and Web service


Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them.

FeaturesWeb ServiceWCF
HostingIt can be hosted in IISIt can be hosted in IIS, windows activation service, Self-hosting, Windows service
Programming[WebService] attribute has to be added to the class[ServiceContraact] attribute has to be added to the class
Model[WebMethod] attribute represents the method exposed to client[OperationContract] attribute represents the method exposed to client
OperationOne-way, Request- Response are the different operations supported in web serviceOne-Way, Request-Response, Duplex are different type of operations supported in WCF
XMLSystem.Xml.serialization name space is used for serializationSystem.Runtime.Serialization namespace is used for serialization
EncodingXML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, CustomXML 1.0, MTOM, Binary, Custom
TransportsCan be accessed through HTTP, TCP, CustomCan be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
ProtocolsSecuritySecurity, Reliable messaging, Transactions

Features of WCF

  • Service Orientation
  • Interoperability
  • Multiple Message Patterns
  • Service Metadata
  • Data Contracts
  • Security
  • Multiple Transports and Encodings
  • Reliable and Queued Messages
  • Durable Messages
  • Transactions
  • AJAX and REST Support
  • Extensibility
WCF is a replacement for all earlier web service technologies from Microsoft. It also does a lot more than what is traditionally considered as "web services".