Sunday 22 December 2013

Difference


1. DELETE is a DML Command.
2. DELETE statement is executed using a row lock, each row in the table is locked for deletion.
3. We can specify filters in where clause
4. It deletes specified data if where condition exists.
5. Delete activates a trigger because the operation are logged individually.
6. Slower than truncate because, it keeps logs.
7. Rollback is possible.
TRUNCATE 
1. TRUNCATE is a DDL command.
2. TRUNCATE TABLE always locks the table and page but not each row.
3. Cannot use Where Condition.
4. It Removes all the data.
5. TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.
6. Faster in performance wise, because it doesn't keep any logs.
7. Rollback is not possible.
TRUNCATE 
1. TRUNCATE is a DDL command.
2. TRUNCATE TABLE always locks the table and page but not each row.
3. Cannot use Where Condition.
4. It Removes all the data.
5. TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.
6. Faster in performance wise, because it doesn't keep any logs.
7. Rollback is not possible.
Deletes the data as well as structure.
The difference b/w DROP and DELETE table is that, after executing DELETE statement the contents of table are removed but the structure remains same, but in case of DROP statement both the contents and structure are removed.
How ASP.NET different from ASP?

Difference b/w Delete, Truncate, Drop Click here :-
DELETE 


Drop



·                     Asp.Net forms have a code behind file which contains all event handling code But in Asp it doesn't have such facility to separate programming logic form design.
·                     Asp.Net inherits the class written in code behind But in Asp does not have concept of inheritance
·                     Asp.Net use full fledged programming language But Asp it use scripting language.
·                     Asp.Net web application are configuration(web.config) But in Asp there are not.  
Difference B/w Primary key and Unique key.
·                     Primary key is only one in a table but unique key can be more then one.
·                     primary key does not have null value but unique can have one null value.
·                     primary key is by default clustered index but unique is by default non-clustered index.
·                     primary key has reference key in another table and unique key also has reference key in another table.
Clustered index and non clustered index
clustered index is index in with row set are stored in particular format but in non clustered index then is not format.  

Difference B/w Primary key and Foreign key.
·                     Primary key is a unique in table this is only one in a table but primary can be define more then one.
·                     primary key does not have null value but Foreign key have null value.
·                     primary key is by default clustered index. 
Difference B/w ADO and ADO.NET


§     In ADO we have record set and in ADO.NET we have Dataset.
§     In recordset we can only have one table. If we want to accommodate more than one tables we need to do inner join and fill the recordset.
§     Dataset can have multiple tables.
§     All data persist in XML as compared to classic ADO where data persisted in Binary format also.
§     In ADO we have record set and in ADO.NET we have Dataset.
§     In recordset we can only have one table. If we want to accommodate more than one tables we need to do inner join and fill the recordset.
§     Dataset can have multiple tables.
§     All data persist in XML as compared to classic ADO where data persisted in Binary format also.

The difference b/w Data Set  and Data Reader
§     Data Reader provides forward only and read only access to data, while the Data set objects can hold more than one table from the same data source as well as the relationships between them.
§     Dataset is a disconnected architecture while data reader is connected architecture.
§     Dataset can persist contents while data reader cannot persist contents they are forward only.

Difference B/w Data Set & Record set

There are two main differences are :
§     Dataset you an retrieve data from two databases like oracle and sql server and merge them in one dataset.
§     Recordset this is not possible
§     All representation of Dataset is using XML while recordset uses COM.
§     Recordset can not be transmitted on HTTP while Dataset can be.

Difference B/w DataAdepter and Datareader.
SqlDataReader:
·      Holds the connection open until you are finished (don't forget to close it!).
·      Can typically only be iterated over once
·      Is not as useful for updating back to the database
On the other hand, it:
·      Only has one record in memory at a time rather than an entire result set (this can be huge)
·      Is about as fast as it you can get for that one iteration
·      Allows you start processing results sooner
SqlDataAdapter/DataSet
·      Lets you close the connection as soon it's done loading data, and may even close it for you automatically
·      All of the results are available in memory
·      You can iterate over it as many times as you need, or even look up a specific record by index
·      Has some built-in faculties for updating back to the database
At the cost of:
·      Much higher memory use
·      You wait until all the data is loaded before using any of it
Abstract Class V/s Interface 

·                     Abstract class can have implementation for some of its method. But the interface can't have implementation for any of its method.
·                      Abstract class can have field but interface does not have fields.
·                     An Interface can inherit from another interface only can't inherit from another abstract class but an abstract class can inherit from another abstract class and another interface.
·                     Abstract class members can have access modifiers where interface member doesn't have access modifiers.
Structure V/s Class
·                     Class is a reference type so it is stored in Heap. Structure is value type so it is stored in stack.
·                     class has inheritance but structure does not has inheritance.
·                     In class there is constructor But in structure there may be or may not be constructor.
·                     By default class has private access modifier and structure has public modifier. 


Query String

Interview Questions & Answer on ASP.NET Query Strings

Q : Give an example of using querystrings to send data from one page to another?
Ans : Query strings are a very simple and popular technique to pass data from one Web page to the next. You send data as part of the URL. In the below example FName and LName are sent as part of the URL. In the page load of QueryStrings2.aspx we use Request.QueryString to read the values. As we are sending more than one query string we use the & symbol to seperate query strings.
Q : //Code to send query strings FName and LName as part of the URL
Ans : QueryStrings2.aspx?FName=David&LName=Boon
protected void Page_Load(object sender, EventArgs e)
{
//Code to read Query String values
string FirstName = Request.QueryString["FName"];
string LastName = Request.QueryString["LName"];
Response.Write("Data from QueryStrings1.aspx : " + FirstName + ", " + LastName);
}
Q : Give an example to send Query Strings from code?
Ans : You can send query strings from server side code using the Response.Redirect() method as shown below.
Response.Redirect("QueryStrings2.aspx?FName=David&LName=Boon");
Q : What are the advantages of using Query Strings?
Ans : 1. Query strings are easy to implement.
2. Browser support for passing values in a query string is nearly universal.
3. Query strings are contained in the HTTP request for a specific URL and do not require server resources.
Q : What are the disadvantages of using querystrings to send data from one page to another?
Ans : 1. Query strings are insecure because the information in the query string is directly visible to the user on the address line in the browser.
2. Many browsers impose a 255 URL character limit which can limit their flexibility.

Session in Dot Net

                                                                                                                                                Next......


Q : What is a Session?
Ans : A Session is a unique instance of the browser. A single user can have multiple instances of the browser running on his or her machine. If each instance visits your Web application, each instance has a unique session.A session starts when a user accesses a page on a Web site for the first time, at which time they are assigned a unique session ID. The server stores the user's session ID in the Session.SessionID property.
Q : What is the default session timeout period?
Ans : 20 minutes.
Q : Where do you generally specify the Session Timeout?
Ans : You specify the Session Timeout setting in the web.config file.
Q : Can you specify Session Timeout in a code behind file?
Ans : Yes, can specify the Session.Timeout property as shown below in a code behind file. Session.Timeout = 10;
Q : How do you end a user session?
Ans : You can call the Session.Abandon() method to end a user session. If a user then tries to access a page the server will assign them a new session ID and it will clear all the previous session variables. You'll typically use Session.Abandon() on log-out pages.
Q : What type of data can you store in Application State and Session State variables?
Ans : Application State and Session State variables are used to store data that you want to keep for the lifetime of an application or for the lifetime of a session. You can store any type of data in the Application or Session state, including objects.
Q : Are Application State or Session State variables type safe?
Ans : No, Application and Session state variables are created on the fly, without variable name or type checking.
Q : Do maintaining Session state affects performance?
Ans : Yes
Q : Can you turn of Session state?
Ans : Yes, Session state can be turned off at the application and page levels.
Q : Are Application state variables available throughout the current process?
Ans : Yes, Application state variables are available throughout the current process, but not across processes. If an application is scaled to run on multiple servers or on multiple processors within a server, each process has its own Application state.
Q : How do you disable Session state for a Web form?
Ans : To turn Session state off for a Web form set EnableSessionState property of the Page to False.
Q : How do you turn Session state off for an entire web application?
Ans : In the Web.config file, set the sessionstate tag to False.
Q : What are Application State variables?
Ans : Application State variables are global variables that are available from anywhere in the application. All Sessions can access Application State variables.
Q : How to add and remove data to Application State Variables?
Ans ://Code to add data to Application State
Application.Add("AppName", "Sample");

//Code to remove data from Application State
Application.Remove("A ppName");
Q : How do you remove all Application State Variables data?
Ans : //Code to remove all Application State Variables data
Application.RemoveAll();

Cookies

Interview Questions & Answer on ASP.NET Cookies

Q : What are Cookies in ASP.NET?
Ans : Cookies are small pieces of information stored on the client computer.Use cookies to store small amounts of information on the client’s machine. Web sites often use cookies to store user preferences or other information that is client-specific. Because cookies can be refused, it is important to check whether the browser allows them before you try to create them.They are limited to storing only character data and they are limited to 4K in size.
Q : What are different types of Cookies?
Ans : Session Cookies
Persistent Cookies
Q : What are Session Cookies?
Ans : Session cookies are stored in-memory during the client browser session. When the browser is closed the session cookies are lost.
Q : How can you create Session Cookies?
Ans : You can create session cookies by calling the Add method of the Cookies collection on the Response object. The Cookies collection contains individual cookie objects of type HttpCookie.

//Code to create a UserName cookie containing the name David.
HttpCookie CookieObject = new HttpCookie("UserName", "David");
Response.Cookies.Add(CookieObject);

//Code to read the Cookie created above Request.Cookies["UserName"].Value;
Q : What is the difference between Session Cookies and Persistent Cookies?
Ans : Persistent Cookies are same as Session Cookies except that, persistent cookies have an expiration date. The expiration date indicates to the browser that it should write the cookie to the client's hard drive. Keep in mind that because a user can delete cookies from their machine that there is no guarantee that a cookie you "drop" on a user machine will be there the next time they visit your site.
Q : What are Persistent Cookies used for?
Ans : Persistent cookies are generally used to store information that identifies a returning user to a Web site. Typical information found in Persistent Cookies includes user names or user IDs.
Q : How do you create a Persistent Cookie?
Ans : You create a persistent cookie the same way as session cookies except that you set the Expires property to a Date in the future which will store the Cookie to the client computer harddrive.

//Code to create a UserName Persistent Cookie that lives for 10 days
HttpCookie CookieObject = new HttpCookie("UserName", "David");
CookieObject.Expires = DateTime.Now.AddDays(10);
Response.Cookies.Add(CookieObject);

//Code to read the Cookie created above
Request.Cookies["UserName"].Value;
Q : What is Cookie Dictionary?
Ans :A cookie dictionary is a single cookie object that stores multiple pieces of information. You use the Values property to access and assign new values to the cookie dictionary.
Q : What are the advantages of Using Cookies?
Ans : 1. Cookies do not require any server resources since they are stored on the client.
2. Cookies are easy to implement.
3. You can configure cookies to expire when the browser session ends (session cookies) or they can exist for a specified length of time on the client computer (persistent cookies).
Q : What are the disadvantages of Using Cookies?
Ans : 1. Users can delete a cookies.
2. Users browser can refuse cookies,so your code has to anticipate that possibility.
3. Cookies exist as plain text on the client machine and they may pose a possible security risk as anyone can open and tamper with cookies.
Q : How do you create a Cookie that never expires?
Ans :To create a Cookie that never expires set the Expires property of the Cookie object to DateTime.MaxValue.
Q : Are Cookies secure?
Ans : No, Cookies are not secure. You must pay attention to the type of data you store in cookies.
1. Cookies are not designed to store critical information so storing passwords in a cookie is a bad idea.
2. Keep the lifetime of a cookie as short as practically possible.
3. Encrypt cookie data to help protect the values stored in the cookie.

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...