Difference between stored procedure and function
1) Procedure can
return zero or n values whereas function can return one value which is
mandatory.
2) Procedures can have input, output parameters for it whereas functions can
have only input parameters.
3) Procedure allows select as well as DML statement in it whereas function
allows only select statement in it.
4) Functions can be called from procedure whereas procedures cannot be called
from function.
5) Exception can be handled by try-catch block in a procedure whereas try-catch
block cannot be used in a function.
6) We can go for transaction management in procedure whereas we can't go in
function.
7) Procedures cannot be utilized in a select statement whereas function can be
embedded in a select statement.
What is the differences
between a Primary key and a Unique key?
Primary
key doesn’t allow NULL, a unique key does.
What is the sequence of execution of the ASP.NET page life
cycle?
The simple way is to
remember SILVER.
- S (It is not counted)
- I (Init)
- L (Load)
- V (Validate)
- E (Event)
- R (Render)
Index types in SQL Server
Clustered
Index
Just
1 permitted per table physically modifies the information in the table to
affirm to the list limitations for utilization on segments that are every now
and again looked for scopes of information for utilization on segments with low
selectivity.
Non-Clustered
Index
Up
to 249 permitted per table makes a different rundown of key qualities with
pointers to the information's area in the information pages For utilization on
segments that are hunt down single qualities
A
bunched list is an uncommon kind of file that reorders the path records in the
table are physically put away. In this way table can have stand out bunched
list. The leaf hubs of a bunched list contain the information pages. A
non-bunched file is an uncommon kind of list in which the legitimate request of
the record does not coordinate the physical put away request of the columns on
circle. The leaf hub of a non-grouped record does not comprise of the
information pages. Rather, the leaf hubs contain record columns.
Included
Column Index (New in SQL Server 2005)
In SQL Server 2005,
the usefulness of non-grouped lists is reached out by adding non-key sections
to the leaf level of the non-bunched file. Non-key segments can help to make
spread records. By including non-key sections, you can make non-grouped records
that cover more questions. The Database Motor does not consider non-key
sections when figuring the quantity of list key segments or file key size.
Non-key sections can be incorporated into non-grouped list to abstain from
surpassing the present record size confinements of a greatest of 16 key
segments and a most extreme list key size of 900 bytes. Another favorable
position is that utilizing non-key section as a part of file we can have record
information sorts not permitted as list key segments for the most part.
In following example
column Filename is varchar(400), which will increase the size of the index key
bigger than it is allowed. If we still want to include in our cover index to
gain performance we can do it by using the Keyword INCLUDE.
USE AdventureWorks
GO
CREATE
INDEX IX_Document_Title
ON Production.Document (Title,
Revision)
INCLUDE (FileName)
Non-key
segments can be incorporated just in non-grouped records. Sections can't be
characterized in both the key segment and they Incorporate rundown. Segment
names can't be rehashed in the Incorporate rundown. Non-key sections can be
dropped from a table when the non-key record is dropped first. For Included
Section List to exist there must be no less than one key segment characterized
with a most extreme of 16 key segments and 1023 included segments.
Abstain
from including superfluous sections. Including an excess of list segments, key
or non-key as they will influence contrarily on execution. Less list columns
will fit on a page. This could make I/O expands and diminished store
effectiveness. More circle space will be required to store the file. List
upkeep may expand the time that it takes to perform changes, embeds, redesigns,
or erases, to the hidden table or filed view.
What
is a Distributed System?
A. A
collection of autonomous computers. Find out more http://www.csc.villanova.edu/~schragge/CSC8530/Intro.html
Image
Courtesy : http://msdn.microsoft.com/en-us/library/cc239737.aspx
Explain client side state management system.
ASP.NET provides
several techniques for storing state information on the client. These include the
following:
- view state
ASP.NET uses view state to track values in controls between page requests. It
works within the page only. You cannot use view state value in next page.
- control state:
You can persist information about a control that is not part of the view state.
If view state is disabled for a control or the page, the control state will
still work.
- hidden fields:
It stores data without displaying that control and data to the user’s browser.
This data is presented back to the server and is available when the form is
processed. Hidden fields data is available within the page only (page-scoped
data).
- Cookies:Cookies
are small piece of information that server creates on the browser. Cookies
store a value in the user’s browser that the browser sends with every page
request to the web server.
- Query strings:
In query strings, values are stored at the end of the URL. These values are
visible to the user through his or her browser’s address bar. Query strings are
not secure. You should not send secret information through the query string.
Explain server side state management system.
The following objects
are used to store the information on the server:
-
Application State:
This object stores
the data that is accessible to all pages in a given Web application. The
Application object contains global variables for your ASP.NET application.
-
Cache Object:
Caching is the process of storing data that is used frequently by the user.
Caching increases your application’s performance, scalability, and
availability. You can catch the data on the server or client.
-
Session State:
Session object stores user-specific data between individual requests. This
object is same as application object but it stores the data about particular
user.
How can we create a new table in SQL with only the structure?
Here is the query to
do that.
Select
* Into<B>From<A>Where1 = 2
Points to be noted:
- A is the source table.
- B is the destination table.
- The condition 1=2 is to prevent
the data from being copyied.
Explain cookies with example.
A cookie
is a small amount of data that server creates on the client. When a web server
creates a cookie, an additional HTTP header is sent to the browser when a page
is served to the browser. The HTTP header looks like this:
Set-Cookie:
message=Hello. After a cookie has been created on a browser, whenever the
browser requests a page from the same application in the future, the browser
sends a header that looks like this:
Cookie:
message=Hello
Cookie is
little bit of text information. You can store only string values when using a
cookie. There are two types of cookies:
-
Session cookies
- Persistent cookies.
A session
cookie exists only in memory. If a user closes the web browser, the session
cookie delete permanently.
A
persistent cookie, on the other hand, can available for months or even years.
When you create a persistent cookie, the cookie is stored permanently by the
user’s browser on the user’s computer.
Creating
cookie
protected
void btnAdd_Click(object sender, EventArgs e)
{
Response.Cookies[“message”].Value = txtMsgCookie.Text;
}
//
Here txtMsgCookie is the ID of TextBox.
// cookie names are
case sensitive. Cookie named message is different from setting a cookie named
Message.
The above
example creates a session cookie. The cookie disappears when you close your web
browser. If you want to create a persistent cookie, then you need to specify an
expiration date for the cookie.
Response.Cookies[“message”].Expires
= DateTime.Now.AddYears(1);
Reading
Cookies
void Page_Load()
{
if (Request.Cookies[“message”] != null)
lblCookieValue.Text = Request.Cookies[“message”].Value;
}
// Here lblCookieValue
is the ID of Label Control.
Describe the disadvantage of
cookies.
- Cookie
can store only string value.
- Cookies are browser dependent.
- Cookies are not secure.
- Cookies can store small amount of data.
How
to change the name of the table or stored procedure in sql?
Ans: sp_rename oldtablename newtablename
For changing the
column name
Sp_rename
‘tablename.[Oldcolumnname]’,’newcolumnname’,’Column’
Ex:sp_rename
‘tblemp.first’,’namechange’,’Column’
How
to find out which index is defined on table?
Ans: sp_helpindex tablename
Can
you write the program to find the length of string without using library
function?
Ans: for (int i=0; str[i]!=”\n”; i++)
{
Count++;
}
What is partial class?
There are the
following situations of when splitting a class definition is desirable:
- To work with large projects.
- To split the class definitions as
we needed with the keyword partial.
What
are difference between GET and POST Methods?
Ans:
GET
Method ():
1) Data is appended to the URL.
2) Data is not secret.
3) It is a single call system
4) Maximum data that can be sent is 256.
5) Data transmission is faster
6) this is the default method for many browsers
POST Method ():
1) Data is not appended to the URL.
2) Data is Secret
3) it is a two call system.
4) There is no Limit on the amount of data. That is characters any amount of
data can be sent.
5) Data transmission is comparatively slow.
6) No default and should be explicitly specified.
What is Session object?
Describe in detail.
HTTP is a
stateless protocol; it can't hold the user information on web page. If user
inserts some information, and move to the next page, that data will be lost and
user would not able to retrieve the information. For accessing that information
we have to store information. Session provides that facility to store
information on server memory. It can support any type of object to store. For
every user Session data store separately means session is user specific.
Storing
the data in Session object.
Session
[“message”] = “Hello World!”;
Retreving
the data from Session object.
Label1.Text
= Session[“message”].ToString();
What are the Advantages and
Disadvantages of Session?
Following
are the basic advantages and disadvantages of using session.
Advantages:
- It
stores user states and data to all over the application.
- Easy
mechanism to implement and we can store any kind of object.
- Stores
every user data separately.
- Session
is secure and transparent from user because session object is stored on the
server.
Disadvantages:
-
Performance overhead in case of large number of user, because of session data
stored in server memory.
- Overhead
involved in serializing and De-Serializing session Data. Because In case of
StateServer and SQLServer session mode we need to serialize the object before
store.
What are the advantages of .Net?
- Good Design
- Object-Oriented Programming –
Using C# and .NET which are based on object-oriented Concepts.
- Language Independence – All the
languages which are supported by .Net (VB.NET, C#, J#, and managed C++)
are compiled into common Intermediate Language (IL). So IL makes sure that
languages are interoperable.
- Efficient Data Access – ADO.NET
provides fast and efficient way to access RDBMS, file system etc.
- Code Sharing – To share code
between applications, a new concept called assembly is introduced.
Assemblies supports versioning.
- Improved Security
- Support Dynamic Web Pages – Using
ASP.NET
- Support for Web Services
What is .Net Framework ?
The .NET framework is
a programming framework from Microsoft. Developers can use .Net Framework to
develop applications, install and run the application on Windows operating
systems.
What is MS-IL (Microsoft Intermediate Language) ?
When a program is
complied in .Net, the source code will be converted into an intermediate
language called Microsoft Intermediate Language (MS-IL). This is done by
Just-In time Compiler (JIT). The dot net framework is built in such a way that
the code is Just-In time complied, which means that it get complied when it is
called rather than compiling entire code at the start up. A portion of the code
will get complied only once and it will exist till the application exit. This
will have a significant improvement in performance since the entire section of
the code won't get executed in most cases.
How is .NET able to support
multiple languages?
A language
should comply with the Common Language Runtime standard to become a .NET
language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL
for short). This is called as Managed Code. This Managed code is run in .NET
environment. So after compilation to this IL the language is not a barrier. A
code can call or use a function written in another language.
What
is the difference Grid View and between Data Grid (Windows)?
Ans:
1) GridView Control
Enables you to add sorting, paging and editing capabilities without writing any
code.
2)GridView Control Automatically Supports paging by setting the ‘PagerSetting’
Property.The Page Setting Property supports four Modles
a. Numeric(by default)
b. Next Previous
c. NumericFirstLast
d. Next PreviousLast
3)It is Used in asp.net
4)GridView Supports RowUpdating and RowUpdated Events.
5)GidView is Capable of Pre-Operations and Post-Operations.
6)GridView Has EditTemplates for this control
7)It has AutoFormat
What
are the different levels of State management in ASP.NET?
Ans:
State management is
the process by which you maintain state and page information over multiple
requests for the same or different pages.
There are 2 types State Management:
1. Client – Side State Management
This stores information on the client's computer by embedding the information
into a Web page, a uniform resource locator (url), or a cookie. The techniques
available to store the state information at the client end are listed down
below:
a. View State – Asp.Net uses View State to track the values in the Controls.
You can add custom values to the view state. It is used by the Asp.net page
framework to automatically save the values of the page and of each control just
prior to rendering to the page. When the page is posted, one of the first tasks
performed by page processing is to restore view state.
b. Control State – If you create a custom control that requires view state to
work properly, you should use control state to ensure other developers don’t
break your control by disabling view state.
c. Hidden fields – Like view state, hidden fields store data in an HTML form
without displaying it in the user's browser. The data is available only when
the form is processed.
d. Cookies – Cookies store a value in the user's browser that the browser sends
with every page request to the same server. Cookies are the best way to store
state data that must be available for multiple Web pages on a web site.
e. Query Strings - Query strings store values in the URL that are visible to
the user. Use query strings when you want a user to be able to e-mail or
instant message state data with a URL.
2. Server – Side State Management
a. Application State - Application State information is available to all pages,
regardless of which user requests a page.
b. Session State – Session State information is available to all pages opened
by a user during a single visit.
Both application state and session state information is lost when the
application restarts. To persist user data between application restarts, you
can store it using profile properties.
When to use an override and new in C#?
- We can use override when there is
virtual/abstract/override type of method in base class.
- We can use New when there is no
virtual/abstract/override type of method in base class.
What's the difference between IEnumerable<T> and
List<T> ?
1. IEnumerable is an interface, where as List is
one specific implementation of IEnumerable. List is a class.
2. FOR-EACH
loop is the only possible way to iterate through a collection of IEnumerable,
where as List can be iterated using several ways. List can also be indexed by
an int index, element can be added to and removed from and have items inserted
at a particular index.
3. IEnumerable
doesn't allow random access, where as List does allow random access using
integral index.
4. In general
from a performance standpoint, iterating thru IEnumerable is much faster than
iterating thru a List.
Difference between EXE and DLL?
1. .EXE
is an executable file and can run by itself as an application, where as .DLL is
usullay consumed by a .EXE or by another .DLL and we cannot run or execute .DLL
directly.
2. For
example, In .NET, compiling a Console Application or a Windows Application
generates .EXE, where as compiling a Class Library Project or an ASP.NET web
application generates .DLL. In .NET framework, both .EXE and .DLL are called as
assemblies.
What are the difference between interfaces and
abstract classes?
1. Abstract
classes can have implementations for some of its members, but the interface
can't have implementation for any of its members.
2. Interfaces
cannot have fields where as an abstract class can have fields.
3. An
interface can inherit from another interface only and cannot inherit from an
abstract class, where as an abstract class can inherit from another abstract
class or another interface.
4. A class
can inherit from multiple interfaces at the same time, where as a class cannot
inherit from multiple classes at the same time.
5. Abstract
class members can have access modifiers where as interface members cannot have
access modifiers.
What is a delegate?
A delegate is a type safe function pointer.
Using delegates you can pass methods as parameters. To pass a method as a
parameter, to a delegate, the signature of the method must match the signature
of the delegate. This is why, delegates are called type safe function pointers.
What is the main use of delegates in C#?
Delegates are mainly used to define call back
methods.
What are the advantages of using interfaces?
Interfaces are very powerful. If properly used,
interfaces provide all the advantages as listed below.
1. Interfaces
allow us to implement polymorphic behaviour. Ofcourse, abstract classes can
also be used to implement polymorphic behaviour.
2. Interfaces
allow us to develop very loosely coupled systems.
3. Interfaces
enable mocking for better unit testing.
4. Interfaces
enables us to implement multiple class inheritance in C#.
5. Interfaces
are great for implementing Inverson of Control or Dependancy Injection.
6. Interfaces
enable parallel application development.
What are the advantages and disadvantages of
using arrays?
Advantages of using arrays:
1. Arrays are
strongly typed, meaning you can only have one type of elements in the array.
The strongly typed nature of arrays gives us
2 advantages.
One, the performance will be much better because boxing and unboxing will not
happen. Second, run time errors can be prevented because of type mis matches.
Type mis matches and runtime errors are most commonly seen with collection
classes like ArrayList, Queue, Stack etc, that are present in
System.Collections namespace.
Disadvantages
of using arrays:
1. Arrays are
fixed in size and cannot grow over time, where ArrayList in System.Collections
namespace can grow dynamically.
2. Arrays are
zero index based, and hence a little difficult to work with. The only way to
store or retrieve elements from arrays, is to use integral index. Arrays donot
provide convinient methods like Add(), Remove() etc provided by collection
classes found in System.Collections or System.Collections.Generics namespaces,
which are very easy to work with.