DataReader vs DataSet vs DataAdapter

Difference between DataReader,DataSet and DataAdapter

S.NoDataReaderDataSet / DataAdapter
1
Database Connecting Mode:
Connected mode
Database Connecting Mode:
Disconnected mode
2
Data Navigation:
Unidirectional i.e., Forward Only
Data Navigation:
Bidirectional i.e., data can navigate back and forth
3
Read / Write:
Only Read operation can be carried out.
Read / Write:
Both Read and Write operations are possible
4
Data Handling:
Handles Database table
Data Handling:
Handles text file, XML file and Database table
5
Storage Capacity :
No storage
Storage Capacity :
Temporary Storage Capacity i.e., in-memory cache of data
6
Accessibility :
Can access one table at a time
Accessibility :
Can access multiple table at a time
7
Speed:
Much faster than DataSet
Speed:
Less faster than data reader


Database vs Schema

Difference between Database and Schema

S.NoDatabaseSchema
1
Database is a collection of organized data
Database schema describes the structure and organization of data in a database system
2The database holds the records, fields and cells of dataSchema contains Databases and describes how these database fields and cells are structured and organized and what types of relationships are mapped between these entities


DataTable vs DataSet

Difference between DataTable and DataSet

S.NoDataTableDataSet
1
Meaning:
A DataTable is an in-memory representation of a single database table which has collection of rows and columns.
Meaning:
A DataSet is an in-memory representation of a database-like structure which hascollection of DataTables.
2
Number of rows retrieved at a time:
DataTable fetches only one TableRow at a time
Number of rows retrieved at a time:
DataSet can fetch multiple TableRows at a time
3
Provision of DataRelation Objects:
As DataTable is a single database table, so there is no DataRelation object in it.
Provision of DataRelation Objects:
In DataSet, DataTable objects can be related to each other with DataRelation objects.
4
Enforcing Data Integrity:
In DataTable, there is no UniqueConstraint and ForeignKeyConstraint objects available.
Enforcing Data Integrity:
In DataSet, data integrity is enforced byusing the UniqueConstraint and ForeignKeyConstraint objects.

5
DataSource can be Serialized or Not:
In DataTable, DataSource cannot be serialized.
DataSource can be Serialized or Not:
DataSet is serialized DataSource .That is why web services can always returns DataSet as the result but not the DataTables.

Example for DataTable:

sqldataadapter da = new SqlDataAdater("select * from Employee", con);
DataTable dt = new DataTable();
da.Fill(dt);
datagridview1.DataSource = dt;

Example for DataTable:
sqldataadapter da= new SqlDataAdater("select * from Employee", con);
DataSet ds = new DataSet();
da.Fill(ds);
datagridview1.DataSource = ds.table[0];


Difference between div and table

Difference between div and table

S.NoDivTable
1
Purpose:
To display block of HTML and data
Purpose:
To display Text and in fewer cases images as well.
2
Layout / Type:
DIV is floating type and can divide our webpage into multiple divisions..So,Divs are more flexible--as they do not strict to tabular layouts.
Layout / Type:
Table is Fixed type and consists of table rows(tr), table data(td),table header(th)..So,tables are strict for those layouts which are more tabular.
3
Search Engine Friendly:
Div is better for SEO
Search Engine Friendly:
Table is not Search engine friendly
4
Loading Time:
The loading time of DIV based website is faster than Table based website.
Loading Time:
The loading time of table based website is not faster than DIV based website.
5
Website Alignment:
In DIV,we can control the website alignment by CSS which is comparatively easier than table
Website Alignment:
Table does not make use of CSS, hence website alignment is comparatively difficult
6
Website Changes:
In Div, designers can make a single change to the CSS and it will modify the entire website.
Website Changes:
In table, designers cannot make a single change as like DIV
7
Does CSS Knowledge required ?For Div based layout, we should have knowledge about CSS. Otherwise, we cannot control the Div based website errors.
Does CSS Knowledge required ?
Table based website does not require CSS Knowledge in oder to control the website errors


RegisterClientScriptBlock vs RegisterStartupScript

Difference between Page.RegisterClientScriptBlock and Page.RegisterStartupScript

S.NoPage.RegisterClientScriptBlockPage.RegisterStartupScript
1RegisterClientScriptBlock places the script at the top of the page right after the starting 'form' tag .RegisterStartupScript places the script at bottom of page right before the ending 'form' tag.
2
The code cannot access any of the form's elements because, at that time, the elements have not been instantiated yet.
The code can access any of the form's elements because, at that time, the elements have been instantiated.

3
RegisterClientScriptBlock is meant for functions that should be "available" to the page. For this they are rendered at the start of the HTML file. In this case the page content will be blocked.

RegisterStartupScript is meant for commands that should execute on page load (at the client), so that page needs to be available for the script. This script is rendered at the end of the HTML file. In this case the content of the page will be diplayed first and then script will run.

Example for RegisterStartupScript:

if (!Page.IsStartupScriptRegistered("CH"))

Page.RegisterStartupScript("CH", "script goes here");

Example for RegisterClientScriptBlock:

if (!Page.IsClientScriptBlockRegistered("CH"))

Page.RegisterClientScriptBlock("CH", "script goes here");


Note:

The choice of which method to use really depends on the "order" in which we want our script to be run by the browser when rendering the page.

Take an example of a javascript function that populates a Textbox using a javascript function when a page is loaded. If we use the RegisterClientScriptBlock method, the javascript function will give an error. This is because our script is placed at the top of the page when it was loaded (when the textbox was not even created). So how can it find the textbox and populate the values. So in this case RegisterStartupscript should be used.


UniqueID vs ClientID

Difference between UniqueID and ClientID

S.NoUniqueIDClientID
1
Meaning:
UniqueID is also a uniquely identifiable ID for a control but only used by ASP.Net page framework to identify the control.

i.e., UniqueID = HTML's name attribute
Meaning:
ClientID is a unique ID string that is rendered to the client to identify the control in the output HTML.

i.e., ClientID = HTML's id attribute
2
Delimiter used:
It uses $ to include parent controls (container) ID to make it unique.

For example, ct100$ContentPlaceHolder1$txtLogin
Delimiter used:
It uses _ to include parent controls (container) ID to make it unique.

For example, ct100_ContentPlaceHolder1_txtLogin.
3
UniqueID Generation:
Similar to ClientID, UniqueID is also generated by appending the parent container's(parent control) ID with the original control id but with $ delimiter
ClientID Generation:
The client id for control will be generated by appending the parent container's(parent control) ID with the original control id with "_" as delimeter. In our example, ContentPlaceHolder1 is the ContentPlaceHolder ID of the master page which is the parent container for txtLogin.
4
How to get UniqueID of a control ?
For example, use txtLogin.UniqueID for ct100$ContentPlaceHolder1$txtLogin
How to get CientID of a control ?
For example, use txtLogin.ClientID for ct100_ContentPlaceHolder1_txtLogin.
5
Where to use ?
The unique id is used by the ASP.NET framework to identify the control when the page is posted back to the server.

i.e., UniqueID is used for server-side
Where to use ?
The client id can be used to identify the control in client side scripting like javascript.

i.e., ClientID is used for client-side

Note:
ClientID = HTML's id attribute and so when doing getElementById, we should always give the ClientId.
Instead, if we give UniqueID i.e., getElementById(Element's name), FireFox will fail.

PlaceHolder vs ContentPlaceHolder

Difference between PlaceHolder and ContentPlaceHolder

S.NoPlaceHolderContentPlaceHolder
1
A PlaceHolder control is used as a container for any controls we wish to add and can be used on any page.
A ContentPlaceHolder is used to hold content from Content Pages and can only be used on a Master Page.


Panel vs PlaceHolder

Difference between Panel and PlaceHolder

S.NoPanelPlaceHolder
1
What tag rendered in output ?
Panel will render Div tags in the brower
What tag rendered in output ?
PlaceHolder will not render any tags
2
Does it provide Styling Attributes ?
Panel have the styling capabilites, so we can set the cssclass or style properties such as background-color, forecolor etc..
Does it provide Styling Attributes ?
Placeholder does not have any style attributes associated. We can not set cssclass or forecolor etc...
3
Automatic Width Adjustment:Panel cannot adjust width automatically if controls are added in it.
Automatic Width Adjustment:PlaceHolder can adjust width automatically if controls are added in it.
4
Memory Size: Panel is heavy in memory size as compare to PlaceHolder
Memory Size:PlaceHolder is light in memory size as compare to Panel.
5
When to use ? If we want to use it to separate controls visually, then we have to use Panel control.

When to use ? If we just want a container, without all the Display properties, then we have to use PlaceHolder control.

Difference between URL and URI

Difference between a URL and a URI

S.NoURLURI
1
URL stands for Uniform Resource Locator
URI stands for Uniform Resource Identifier
2
URL is a subset of URI that specifies where an identified resource is available and the mechanism for retrieving it.Meachanism actually means one of the potocol schemes (e.g., http, ftp, file, mailto) provided by URI.
A URI is a superset of URL that identifies a resource either by location (URL), or a name(URN), or both (URL and URN).

Examples for URL:

• http:/www.dotnetfunda.com/users/login.aspx
Here, http is the protocol, dotnetfunda.com is the domain name, users is the folder name, login.aspx is the filename
• http://dotnetfunda.com/articles/default.aspx
Here http is the protocol, dotnetfunda.com is the domain name, articles is the folder name and default.aspx is the file name

Examples for URI:

• www.dotnetfunda.com
• /some/page.html

Summary:
  1. A URI is either a URL or a URN.
  2. Every URL is a URI.
  3. Every URN is a URI.
  4. A URN is never a URL.
  5. A URL is never a URN.
  6. Every URI is not a URL
  7. If the URL describes both the location and name of a resource, the term to use is URI. Since this is generally the case most of us encounter everyday, URI is the correct term.

Here,

URI --> A Uniform Resource Identifier(URI) is used to identify something on the World Wide Web.

URN --> Uniform Resource Name (URN), a type of URI, basically states what something is, but do not have information on how to access it.

URL --> Uniform Resource Locator (URL), a type of URI, contains the location of something and tell the client program (usually a browser) how to access it.


ASP Session vs ASP.NET Session

Difference between ASP Session and ASP.NET Session

S.NoASP SessionASP.NET Session
1
Session type support:
As ASP only supports InProc Session, so it cannot span across multiple servers.
Session type support:
ASP.NET supports both InProc and OutProc (StateServer and SQLServer) Sessions.Hence, it can span across multiple servers.
2
Process dependency:
In ASP, the session is Process dependent i.e., ASP session state is dependent on IIS process very heavily. So if IIS restarts
ASP session variables are also recycled.
Process dependency:
In Asp.Net, the session is Process independent i.e., ASP.NET session can be independent of the hosting environment thus ASP.NET session can maintained even if IIS reboots.
3
Cookie dependency:
In ASP, the session is Cookie dependent i.e., ASP session only functions when browser supports cookies.
Cookie dependency:
As ASP.NET supports Cookieless session, so the session in ASP.NET is Cookie independent.


Authentication vs Authorization

Difference between Authentication and Authorization in ASP.NET 

S.NoAuthenticationAuthorization
1
Meaning:
Authentication is the process of verifying the identity of a user.
Meaning:
Authorization is process of checking whether the user has access rights to the system.
2
Example:
Suppose, we have 2 types of users ( normal and admins ) to a website. When the user tries to access the website, we ask them to log in. This is authentication part.
Example:
Once we know the user is valid, then we determine to which pages the user has access to. Normal users should not be able to access admin pages. This is authorization part.
3
Types of Authentication:
Windows Authentication
Forms Authentication
Passport Authentication
Types of Authorization:
ACL authorization (also known as file authorization)
URL authorization
4
Whent it takes place ?
Authentication always precedes to Authorization,event if our application lets anonymous users connect and use the application,it still authenticates them as anonymous.
Whent it takes place ?
Authorization takes place after Authentication


EnableViewState vs ViewStateMode

Difference between EnableViewState and ViewStateMode properties 

S.NoEnableViewStateViewStateMode
1
Property Introduction:
EnableViewState exists from a long time
Property Introduction:
ViewStateMode property is introduced in ASP.NET 4
2
Available Values:
EnableViewState property only accepts true or false values
Available Values:
ViewStateMode property can have a value of - Enabled, Disabled and inherit.
3
Default Value:
True
Default Value:
Inherit
4
What EnableViewState does ?
To enable ViewState at Page level
What ViewStateMode does ?
To enable ViewState at Control level
5
How to use ?
Using EnableViewState property we can have one of these 2 options.

i. We can turn off view state altogether by setting its value to false in web.config file,or
ii.Enable viewstate for the entire pageand then turn it off on a control-by-control basis.
How to use ?
Steps involved to disable view state for a page and to enable it for a specific controlon the page,

i. Set the EnableViewState property of thepage and the control to true,
ii. Set the ViewStateMode property of thepage to Disabled, and
iii. Set the ViewStateMode property of thecontrol to Enabled.

Difference between STA and MTA

Difference between STA and MTA

S.NoSTAMTA
1STA stands for Single Threaded Apartment
MTA stands for Multi Threaded Apartment
2In STA,there may be multiple apartment.But only single thread can be executed in a apartment.In MTA, only one apartment will be there and all threads will execute within that single apartment.
3In STA, if there is a need to communicate between threads we need a proxy, they can not do it directly.In MTA, threads communicate directly to each other without a proxy.
4MTA applications execute slower than STAMTA applications typically execute faster than STA because there is less system overhead and can be optimized to eliminate system idle time.
5If the COM object cannot handle its own synchronization i.e not thread safe then the STA model can be usedIf the COM object can handle its own synchronization then the MTA model can be used

Summary:
An apartment is a logical container within a process for objects sharing the same thread access requirements.

All objects in the same apartment can receive calls from any thread in the apartment.

The .NET Framework does not use apartments, and managed objects are responsible for using
all shared resources in a thread-safe manner themselves.

Weak-named vs Strong-named .NET components

Difference between Weak-named .NET components and Strong-named .NET components

S.NoWeak-named .NET componentsStrong-named .NET components
1Weak names are not guaranteed to be unique and thus cannot be shared without potentially causing conflicts.
Strong names are digitally signed and provide a public key that ensures there are no conflicts.
2Weak-named .NET components must be individually copied to the /bin directories of the Web applications where they are used.
Strong-named .NET components can be copied into the server’s GAC

3.NET components with weak names can call unmanaged code (such as COM components) and thus causes potential conflicts with dependencies.Furthermore, .NET components with strong names cannot call unmanaged code (such as COM components) and thus avoid potential conflicts with dependencies.


Functions vs Methods

Difference between Functions and Methods

S.NoFunctionsMethods
1Functions do not have any reference variables
Methods are called by reference variables
2All data that is passed to a function is explicitly passedIt is implicitly passed the object for which it was called
3It does not have access controlling i.e.,Function(other than static functions) declares and defines anywhere in the code
It has access controlling i.e.,Method should declare and define in the class only


4Function applies to both object oriented and non-object oriented language(procedural language.eg. C, Scripting language eg; JavaScript etc)Method is only applicable to object oriented programming language like C++, C#, Java etc