Sunday, April 25, 2010

fundamental questions

One of my friend had been to one interview in last weekend and the questions he had faced are below.I see that all the questions were asked looks like we use them in our daily programming .But when look at the them first time,It is giving me strange feeling because the technical names of that concepts I have not known.

What is cross page posting in ASP.Net...?

Cross-page posting is desired in a scenario where data is collected on one Web page and processed on another Web page. ASP.NET  2.0 introduces a new property in the Page class called ‘PreviousPage’ which gets the page that posted to the current
page .

ASP.NET by default, submits the form to the same page. Cross page posting is submitting the form to a different page. This is usually required when you are creating a multi page form to collect information from the user on each page. When moving from the source to the target page, the values of controls in the source page can be accessed in the target page.

What is SCOPE_IDENTITY() :-

This function can return the last identity value inserted into an identity column in the same scope e.g. a stored procedure, trigger, function, or batch. .
Here is the example that will tell how to use scope_identity() function

CREATE PROCEDURE Employee(
@EmpName VARCHAR(50),
@EmpEmail VARCHAR(50),
@PhoneNo VARCHAR(50),
@EmpID INT OUTPUT)
AS
BEGIN
INSERT INTO Employee (EmpName, EmpEmail , PhoneNo)
VALUES (@EmpName,@EmpEmail,@PhoneNo)
 
SET @EmpID = CAST(SCOPE_IDENTITY() AS INT)
EN
 
 
What is current Identity : 

Returns the last identity value generated for a specified table or view.
The last identity value generated can be for any session and any scope.

USE AdventureWorks;
GO
SELECT IDENT_CURRENT ('Person.Address') AS Current_Identity;
GO 

No comments: