Sunteți pe pagina 1din 7

Homework type/no: _4 INT__302_____ Course instructor: _Miss.

Cherry khosla_ tutor:__ Date of allotment: _4/11/2010______ submission: 18/11/2010__ Student roll no: __A11_ __RD2802__

Course code: course Date of Section no:-

Declaration: I declare that this assignment is my individual work. I have not copied from any other students work or from any other source except where due acknowledgment is made explicitly in the text, nor has been written for me another person. Students signature: AJAY SHARMA Evaluators comments: Marks obtained _____________________ of________________________ Content of home work should start from this page only out

1|Page

PART A
Q1. You first create a form that contains the fields you want to collect data from: Customer id, company name, contact name, address, city, postal code, country. When the user presses the submit button the form is sent to a file called "demo_add.asp". The "demo_add.asp" file contains the code that will add a new record to the Customers table. ANS:- Add a Record to a Table in a Database:We want to add a new record to the Customers table in the Northward database. We first create a form that contains the fields we want to collect data from: <html> <body> <form method="post" action="demo_add.asp"> <table> <tr> <td>CustomerID:</td> <td><input name="customerid"></td> </tr><tr> <td>Company Name:</td> <td><input name="companyname"></td> </tr><tr> <td>Contact Name:</td> <td><input name="contactname"></td> </tr><tr> <td>Address:</td> <td><input name="address"></td> </tr><tr> <td>City:</td> <td><input name="city"></td> </tr><tr> <td>Postal Code:</td> <td><input name="postcode"></td> </tr><tr> <td>Country:</td> <td><input name="country"></td> </tr> </table> <br /><br /> <input type="submit" value="Add New"> <input type="reset" value="Cancel"> </form> 2|Page

</body> </html> When the user presses the submit button the form is sent to a file called "demo_add.asp". The "demo_add.asp" file contains the code that will add a new record to the Customers table: <html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" sql="INSERT INTO customers (customerID,companyname," sql=sql & "contactname,address,city,postalcode,country)" sql=sql & " VALUES " sql=sql & "('" & Request.Form("custid") & "'," sql=sql & "'" & Request.Form("compname") & "'," sql=sql & "'" & Request.Form("contname") & "'," sql=sql & "'" & Request.Form("address") & "'," sql=sql & "'" & Request.Form("city") & "'," sql=sql & "'" & Request.Form("postcode") & "'," sql=sql & "'" & Request.Form("country") & "')" on error resume next conn.Execute sql,recaffected if err<>0 then Response.Write("No update permissions!") else Response.Write("<h3>" & recaffected & " record added</h3>") end if conn.close %> </body> </html> Q2. Suppose you are working on a table named Customers and you want to display the "Companyname" and "Contactname" fields from the "Customers" table, ordered by "Companyname". Write the code snippet to sort the records on a specified fieldname using the concept of ADO. ANS:- <html> <body> <%set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" 3|Page

conn.Open "c:/webdata/northwind.mdb" set rs = Server.CreateObject("ADODB.recordset") sql="SELECT Companyname, Contactname FROM Customers ORDER BY CompanyName" rs.Open sql, conn %> <table border="1" width="100%"> <tr> <%for each x in rs.Fields response.write("<th>" & x.name & "</th>") next%> </tr> <%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%></td> <%next rs.MoveNext%> </tr> <%loop rs.close conn.close%> </table> </body> </html> Q3. Suppose you want to send information from one page to another using the concept of cookies. But what if a browser does not support cookies? ANS:- If our application deals with browsers that do not support cookies, we will have to use other methods to pass information from one page to another in our application. There are two ways of doing this: 1. Add parameters to a URL You can add parameters to a URL: <a href="welcome.asp?fname=John&lname=Smith">Go to Welcome Page[/url] And retrieve the values in the "welcome.asp" file like this: <% fname=Request.querystring("fname") lname=Request.querystring("lname") response.write("<p>Hello " & fname & " " & lname & "!</p>") 4|Page

response.write("<p>Welcome to my Web site!</p>") %> 2. Use a form You can use a form. The form passes the user input to "welcome.asp" when the user clicks on the Submit button: <form method="post" action="welcome.asp"> First Name: <input type="text" name="fname" value="" /> Last Name: <input type="text" name="lname" value="" /> <input type="submit" value="Submit" /> </form> Retrieve the values in the "welcome.asp" file like this: <% fname=Request.form("fname") lname=Request.form("lname") response.write("<p>Hello " & fname & " " & lname & "!</p>") response.write("<p>Welcome to my Web site!</p>") %>

PART B Q4. Discuss the three tier architecture in ASP.NET. Does it help in increasing the reusability of code? ANS:- Three-tier application is a program which is organized into three major disjunctive tiers on layers. Here we can see that how these layers increase the reusability of codes Three Tier Code Code Generator For ASP.NET description The 3-Tier Code Generator is a wonder tool that will help developers to code within minutes a simple module to add, update records in the table. At the same time it keeps the best practices and industry standards in mind. It exploits the object oriented features of .NET. Following are some of the features of the tool: Generates all the code required for 3 tier architecture to be directly used in Visual Studio .NET. Makes use of Web Template pattern and Error pattern. Generates SQL procedures and scripts to create, add, update and show records of the table. Generates code for both C# as well as VB.NET. Can do DataGrid editing or separate update form. Makes use of cascading style sheets. Uses a standard Microsoft recommended Microsoft Data Access Application Block for .NET. User controls are used for header and footer.

5|Page

Q5. Discuss the execution process in .NET environment. ANS:- The managed execution process includes the following steps, which are discussed in detail later in this topic: Choosing a Compiler Compiling to MSIL . Compiling MSIL to Native Code Compilation by the JIT Compiler It performs the conversion from MSIL to native code before running the application instead of while the application is running. It compiles an entire assembly at a time, instead of one method at a time. It persists the generated code in the Native Image Cache as a file on disk.

Code Verification

Q6. Is IIS necessary for publishing the websites under ASP.NET environment? If yes, comment. Also discuss that if you are working in ASP.NET on Linux platform then what would be used to publish the dynamic web pages.? ANS:- YES, IIS is necessary for publishing the websites under ASP.NET. Without IIS we have to face difficulty in publishing the web page

For LINUX environment we use these tool for making the dynamic pages:Mono provides the necessary software to develop and run .NET client and server applications on Linux. It can also be deployed on Solaris, Mac OS X, Windows, and Unix. Mono is dual licensed by Novell, similar to other products such as Qt and the Mozilla Application Suite. Sponsored by 6|Page

Novell, the Mono open source project has an active and enthusiastic contributing community and is positioned to become the leading choice for development of Linux applications. Some Features * Multi-platform * Based on the ECMA/ISO standards * Runs ASP.NET and Winforms applications * Can run .NET, Java, Python and more * Open Source, Free Software Now we come to the main essence of this article, i.e running ASP.NET applications on Linux. <html> <body bgcolor="yellow"> <center> <h2>Hello W3Schools!</h2> <p><%Response.Write(now())%></p> </center> </body> </html>

7|Page

S-ar putea să vă placă și