Dot Net Learning Zone Blog

A blog about to learn Dot Net

Archive for August, 2007

ASP.net 2.0 Question

Posted by Rajesh on August 11, 2007

1.1  Do I need IIS to run Web applications?   

  If you are using Visual Studio, you can use the ASP.NET Development Server built into Visual Studio to test your pages. The server functions as a local Web server, running ASP.NET Web pages in a manner virtually identical to how they run in IIS. To deploy a Web application, you need to copy it to a computer running IIS version 5 or 6.

1.2   How do I create pages for mobile devices?  

   ASP.NET will automatically detect the type of browser making the request. This information is used by the page and by individual controls to render appropriate markup for that browser. You therefore do not need to use a special set of pages or controls for mobile devices. (Whether you can design a single page to work with all types of browsers will depend on the page, on the browsers you want to target, and on your own goals.)

1.3 Are ASP.NET pages XHTML compatible? 

    Yes. Individual controls render markup that is compatible with the XHTML 1.1 standard. It is up to you, however, to include the appropriate document type declaration and other XHTML document elements. ASP.NET does not insert elements for you to ensure XHTML compatibility. For details, see ASP.NET and XHTML Compliance.

1.4 Can I hide the source code for my page?    

Server-side code is processed on the server and is not sent to the browser, so users cannot see it. However, client script is not protected; any client script that you add to your page, or that is injected into the page by server processing, is visible to users. If you are concerned about protecting your source code on the server, you can precompile your site and deploy the compiled version. For details, see Publishing Web Sites.

  1.5 When I run a page, I get the error “The page cannot be displayed” and an HTTP 502 Proxy Error. Why?

     This error can occur if you are running ASP.NET Web pages using the Visual Web Developer Web server, because the URL includes a randomly selected port number. Proxy servers do not recognize the URL and return this error. To get around the problem, change your settings in Internet Explorer to bypass the proxy server for local addresses, so that the request is not sent to the proxy. In Internet Explorer, you can make this change in Tools > Internet Options. In the Connections tab, click LAN Settings and then select Bypass proxy server for local addresses.

1.6 Which page code model is preferable, single-file or code-behind?    

Both models function the same and have the same performance. The choice of using single-file pages versus code-behind pages is one of personal preference and convenience. For details, see ASP.NET Web Page Code Model.The QuickStart examples and examples in the API reference seem to use single-file pages frequently. Does this mean that single-file is the preferred model for pages? No. Single-file pages are frequently used in examples because they are easier to illustrate — the writer does not have to create a separate file to show the code. 

1.7 Is it better to write code in C# or Visual Basic?    

You can write code for your Web application in any language supported by the .NET Framework. That includes Visual Basic, C#, J#, JScript, and others. Although the languages have different syntax, they all compile to the same object code. The languages have small differences in how they support different features. For example, C# provides access to unmanaged code, while Visual Basic supports implicit event binding via the Handles clause. However, the differences are minor, and unless your requirements involve one of these small differences, the choice of programming language is one of personal preference. Once programs are compiled, they all perform identically; that is, Visual Basic programs run just as fast as C# programs, since they both produce the same object code.

1.8 Do I have to use one programming language for all my Web pages?    

No. Each page can be written in a different programming language if you want, even in the same application. If you are creating source code files and putting them in the \App_Code folder to be compiled at run time, all the code in must be in the same language. However, you can create subfolders in the \App_Code folder and use the subfolders to store components written in different programming languages.

 1.9 Is the code in single-file and code-behind pages identical?  

   Almost. A code-behind file contains an explicit class declaration, which is not required for single-file pages.

 1.10 Is the old code-behind model still supported? 

   Old projects will continue to run without change. In Visual Studio 2005, if you open a project created in Visual Studio .NET 2002 or 2003, by default, the project is converted to the new project layout used in Visual Studio 2005. As part of the conversion, pages that use the old code-behind model are converted to use the new code-behind model. Visual Studio 2005 Web Application Projects provide an alternative web project model that uses the same project, build and compilation semantics as the Visual Studio .NET 2003 code-behind model. For details, see Visual Studio 2005 Web Application Projects.

Posted in ASP.net2.0 | Leave a Comment »

FAQ in SQL 2000/2005

Posted by Rajesh on August 11, 2007

Posted in SQL Question | 1 Comment »

New Features inASP.net 2.0

Posted by Rajesh on August 4, 2007

Posted in ASP.net2.0 | Leave a Comment »

Interview question in SQL

Posted by Rajesh on August 3, 2007

Which of the following data types has the highest data type precedence?

A. INT
B. VARCHAR
C. DATETIME
D. FLOAT
E. NUMERIC
F. MONEY

ans :- Here is the order of data type precedence of the given options from highest to lowest: DATETIME, FLOAT, NUMERIC, MONEY, INT and VARCHAR.

2) What’s the maximum number of columns can you include in a SELECT statement?

A. 512
B. 1,024
C. 2,048
D. 4,096

ANS
Although the maximum number of columns a table can have is 1,024, the maximum number of columns that can be specified in a SELECT statement is 4,096.

3) Which of the following is NOT a valid description of the public role?

A. The public role captures all default permissions for users in a database.
B. The public role cannot be dropped.
C. The public role is contained in every database, including msdb, tempdb, model, and all user databases except in the master database for security purposes.
D. The public role cannot have users, groups, or roles assigned to it.

ans:-
All of these statements are valid description of the public role except for the third option because the public role is also contained in the master database.
4)
What will be the output of the following statement?

SELECT CHARINDEX(‘is’, ‘Missississippi’, 0)

A. 0
B. 2
C. NULL
D. Statement will generate an error. The CHARDINDEX function only accepts 2 parameters.

Your Answer : D

Correct Answer : B

Explanation:
The CHARINDEX function returns the starting position of the specified expression in a character string. The third parameter of the CHARINDEX functions is the character position to start searching for the first parameter in the second parameter. If the starting location is 0, the search starts at the beginView text definitions are stored in which system table?

A. sysobjects
B. syscolumns
C. syscomments
D. sysviews

Your Answer : A

Correct Answer : C

Explanation:
The syscomments system table contains entries for each view, rule, default, trigger, CHECK constraint, DEFAULT constraint and stored procedure. The text column contains the original SQL definition statements.
ning of the second parameter.

5)
View text definitions are stored in which system table?

A. sysobjects
B. syscolumns
C. syscomments
D. sysviews

Your Answer : A

Correct Answer : C

Explanation:
The syscomments system table contains entries for each view, rule, default, trigger, CHECK constraint, DEFAULT constraint and stored procedure. The text column contains the original SQL definition statements.

6)
What will be the output of the following statement?

SELECT CHARINDEX(‘is’, ‘Missississippi’, 3)

A. 2
B. 5
C. 8
D. 9
E. -1
F. 0

Your Answer : B

Correct Answer : B

Explanation:
The CHARINDEX function returns the starting position of the specified expression in a character string. The third parameter of the CHARINDEX functions is the character position to start searching for the first parameter in the second parameter.

7
What will be the result of the following statement?

SELECT CAST(-1 AS DATETIME)

A. 1900-01-01 00:00:00.000
B. 1899-01-01 00:00:00.000
C. 1899-12-31 00:00:00.000
D. 1752-01-01 00:00:00.000
E. 1752-12-31 00:00:00.000
F. The statement will generate an error. Only positive integer values can be converted to a DATETIME data type.

Your Answer : F

Correct Answer : C

Explanation:
A DATETIME data type is stored internally in SQL Server as two 4-byte integers. The first 4 bytes store the number of days before or after the base date of January 1, 1900. Given this, a value of 0 corresponds to January 1, 1900 and a value of -1 corresponds to 1 day before the base date, December 31, 1899.

8) What will be the result of the following statement?

SELECT CAST(-1 AS DATETIME)

A. 1900-01-01 00:00:00.000
B. 1899-01-01 00:00:00.000
C. 1899-12-31 00:00:00.000
D. 1752-01-01 00:00:00.000
E. 1752-12-31 00:00:00.000
F. The statement will generate an error. Only positive integer values can be converted to a DATETIME data type.

Your Answer : F

Correct Answer : C

Explanation:
A DATETIME data type is stored internally in SQL Server as two 4-byte integers. The first 4 bytes store the number of days before or after the base date of January 1, 1900. Given this, a value of 0 corresponds to January 1, 1900 and a value of -1 corresponds to 1 day before the base date, December 31, 1899.

Posted in SQL Question | 2 Comments »

Hello world!

Posted by Rajesh on August 3, 2007

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in Uncategorized | 1 Comment »