Vous êtes sur la page 1sur 23

Winter 2009 Q1. Attempt any four: [ Sanjay ] 1. Differentiate between VB and VB.NET. Ans.

The difference in VB and VB.NET are. - The greatest change of VB and VB.NET is of the runtime environment. VB uses VB Runtime while VB.NET uses .NET Common Language Runtime (.NET CLR). - VB6 was interpreted based language while VB.NET is a compiled language. - VB6 is not a type safe language while VB.NET is type safe language. - VB6 used On Error Goto syntax to handle exceptions at runtime, while VB.NET uses trycatch finally syntax to handle exceptions at runtime. - VB.NET has much advanced object oriented support than VB6. - VB6 doesnt allow developing multithreaded applications. In VB.NET multithreaded applications can be created. - VB.NET framework uses NET framework class library along with specialized VB library as a standard library. - VB used ASP to develop web applications, whereas VB.NET uses ASP.NET to develop web applications. 2)What is XML and describe creation of XML file. Ans. XML (Extensible Markup Language) is a set of rules for encoding documents electronically. It is defined in the XML 1.0 Specification produced by the W3C and several other related specifications; all are fee-free open standards. XML unlike HTML allows us to create our own Tags. XML is case sensitive language. XML can be used to store data as like in database. The XML schema contains whole information about the relation structure. It contains information regarding table, constraints and relation. Creation of XML file. In VB.NET XML file can be added to any Solution 1. Right clicking on Solution in Solution Explorer 2. Click on Add new item 3. Then select XMLFile.xml From window which is displayed
Compiled By Prof. Vaibhav Vasani

4. Then XML file is added in project XML Declaration XML documents may begin by declaring some information about them, as in the following example. <?xml version="1.0" encoding="UTF-8" ?> Example Here is a small, complete XML document, which uses all of these constructs and concepts. <? xml version="1.0" encoding='UTF-8'?> <Students> <Student> <Name>ABC</Name> <Roll>11</Roll> </Student> <Student> <Name>PQR</Name> <Roll>22</Roll> </Student> </Students> 2. Differentiate between ASP and ASP.NET A. The difference between ASP and ASP.NET are as follows.

Compiled Environment ASP uses VB Script, thus it is not compiled. ASP.NET uses modern .NET Language like VB.NET. They are compiled to MSIL. When you compile an ASP.NET application, the server side code is compiled to assemblies. These assemblies are loaded at runtime which makes the ASP.NET pages perform better than classic ASP. Based on .NET framework ASP.NET is integral part of .NET and the .NET framework. All the core pieces of ASP.NET are implemented as .NET framework classes. Another advantage of the .NET platform is that its completely language independent.

ADO and ADO.NET

Compiled By Prof. Vaibhav Vasani

Classic ASP uses a technology called ADO to connect and work with databases. ASP.NET uses ADO.NET technology which is the next generation of ADO. Session State Management ASP provides a special collection object where the programmer could store variables pertaining to a particular visitors session. User Input Validation ASP.NET provides a set of server controls that checks the information that user have entered is in the correct form. Caching Services ASP.NET offers two primary caching techniques. Data caching and Output caching. Security In ASP, it was up to the developer to implement his or her own security mechanism especially in the area of user authorization. ASP.NET features built-in security configuration in its application settings files. Debugging and Tracing ASP.NET and Visual Studio.NET aim to solve some of these developer worries by providing advanced debugging tools. Tracing allows developer to inspect and gather important application performance information.

3. List the data types supported by VB.NET with their storage byte length. A. Data Type Size Type Byte 1 System.Byte Char 2 System.Char Integer 4 System.Int32 Double 8 System.Double Long 8 System. Int64 Short 2 System. Int16 Single 4 System.Single String Varies System.String Date 8 System.Date Boolean 2 System.Boolean Object 4 System.Object
Compiled By Prof. Vaibhav Vasani

Decimal

10

System.Decimal

4. Explain how session objects can be used to enable and disable a session. A. Disabling Session: - At application level: In the web.config file locate the tag <sessionState> and set the mode value to Off. Save the file to make the changes. At Page Level: Select the web form and set the EnableSessionState = false in the @ Page tag to disable the session and save the file.

Enabling Session: Set the session state at page level to true or set the session state mode to on at application level. 5. What is data binding? A. Data binding is the process of making a connection between the imported database and the data bound component in the application or web page. This process helps the user to easily access the database in the components and the .NET takes care of the primary operations like next and previous by itself. Data binding are done in two ways.. - With the help of data binding wizard. By manually binding the objects with the data source. 6. Write short note on ASP transaction. A. Transaction is an atomic unit of work that is either done completely or not done at all. ASP transaction code requires the line to make it behave properly. <% @ TRANSACTION = value %> Each page of ASP will be its own transaction. However it is possible to continue transactions across more than one page by using Server.Transfer and Server.Execute method. Q:2 Hema [ Not Submitted ]
Compiled By Prof. Vaibhav Vasani

Q.3 Attempt any three : [Pooja] (a) What is Transaction and how transaction database is designed? Ans: A Transaction is an atomic unit of work that either fails or succeeds as a whole. In a transaction there can be many things to do, like update one thing, delete another, send email, response query and so on. If transaction is successful, all of these things will be done or executed as the case may be or if transaction fails then none of them will be executed. When a transaction is successful, it is said that this transaction has committed and all the tasks that it had to do will be done. If there is some error then the whole transaction will be brought back to its original state and none of task that it had to do will be completed, it is called rolling back of the transaction. Transactions are always executed as a whole. A transaction symbolizes code or a set of components or procedures which must be executed as a unit. All the methods must execute successfully or the complete unit fails. A transaction can be described to cover the ACID properties for mission critical appliances.

(b) Explain the steps necessary to bind single control such a label to field in a dataset. Ans: 1. Open the new windows application in visual studio 2005 2. Place the label control from toolbox on the form. 3. Select the text option of data-binding property of label. 4. While selecting text option it will ask for data-source, select add project data-source. 5. After that, choose data-source type as Database from Data source Configuration Wizard and click NEXT . 6. Choose Data-Source Connection by clicking on New Connection button, further it will display the Add Connection dialog box, in that choose the Database file name by selecting the browse button and then select the respective database file.
Compiled By Prof. Vaibhav Vasani

7. Test the connection to database through Test Connection Button. 8. After the test connection is succeeded, choose your database object by selecting the field from the table which u want to bind to the label control. Then click on Finish button. 9. Since the Database have been included, now it will show the Other Data sources option in the text property. In that select the other data sources, project data sources, Dataset, data table, Field. 10. At last, run your windows application. It will display the respective field in the label.

(c)The Rnebook.mdb database file holds two table, the book table and subject table. The subject table has only two fields: the subject code(the key) and the subject name. write a project that display the subject table in grid. Ans: 1. Open the new windows application in visual studio 2005 2. Place the Data-Grid control from toolbox on the form. 3. Select the Data-source property of Data-Grid Control. 4. While selecting Data-source option it will ask for data-source, select add project data-source. 5. After that, choose data-source type as Database from Data source Configuration Wizard and click NEXT . 6. Choose Data-Source Connection by clicking on New Connection button, further it will display the Add Connection dialog box, in that choose the Database file name by selecting the browse button and then select the respective database file. 7. Test the connection to database through Test Connection Button. 8. After the test connection is succeeded, choose your database object by selecting the table which u want to bind to the Data-Grid control. Then click on Finish button. 9. It will show the Binding source including the name of table.

Compiled By Prof. Vaibhav Vasani

10. At last, run your windows application. It will display the respective table in the Data-Grid.

d) Q4. Attempt Any three:- [ Monica ] a.Write a web application that will display data in datagrid in sorted order. ANS: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <H4>DATAGRID INFORMATION</H4> <body>
Compiled By Prof. Vaibhav Vasani

<form id="form1" runat="server"> <div> <asp:DataGrid ID="DataGrid1" runat="server" DataSourceID="SqlDataSource1"> </asp:DataGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EmployeeConnectionString %>" ProviderName="<%$ ConnectionStrings:EmployeeConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [Emp] ORDER BY [empNo]"></asp:SqlDataSource>

</div> </form> </body> </html>

OUTPUT:-

Compiled By Prof. Vaibhav Vasani

B. Describe Data grid control of ado.net and give example how it is to be connected with database? ANS:A data bound list control that displays the items from data source in a table. The DataGrid control allows you to select, sort and edit these items. Different column types determine the behavior of the column ion the control. The different column types that can be used are as follows:BoundColumn ButtonColumn EditCommandColumn HyperLinkColumn TemplateColumn Following program demonstrates the connection of database to datagrid:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <%@ Import Namespace ="System.data.oledb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <script runat ="server" > Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Compiled By Prof. Vaibhav Vasani

Dim con As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Employee.mdb;") Dim cmd As New OleDbCommand("select * from emp", con) con.Open() DataGrid1.DataSource = cmd.ExecuteReader DataGrid1.DataBind() con.Close()

End Sub </script> <body> <form id="form1" runat="server"> <div> <asp:DataGrid ID="DataGrid1" runat="server"> </asp:DataGrid></div> </form> </body> </html> <asp:datagrid runat="server"></asp:datagrid>

OUTPUT:-

Compiled By Prof. Vaibhav Vasani

C) Write steps to create ASP.NET form with example to print Welcome To World Of ASP.NET Technology? Ans:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <h2><u><b>Welcome To world Of ASP.NET Technology</b></u></h2>

Compiled By Prof. Vaibhav Vasani

</div> </form> </body> </html>

OUTPUT:-

D.Explain the use Of update method with example. Ans:The update method c an submit dataset changes back to the datasource.It uses the statements in a deletecommand, Insertcommand, Updatecommand Objects to attempt to update the datasource with records that have been deleted, inserted or updated in the dataset.Each row is updated individually and not as apart of batch process.

Compiled By Prof. Vaibhav Vasani

E.State Creation and purpose Of Global.ASAx file? Ans: Global.asax file resides in a root directory of an asp.net web application and called ASP.NET Application file. It contains the code that is executed when certain events raised by the ASP.NET Application. It is a file used to control session and application events for an application. Each application can have only one global.asax file attached to it. This file is automatically processed when an application starts and stops. The code written in a global.asax file does not contain html and asp.net tags.The code contains methode with predefined names.

At run time,the Global.asax file parsed and compiled into dynamically generated dotnet framework class derived from the htttp application base class. The Global.asax file itself is configured so that any direct URL request for it is automatically rejected,external users cannot download or view the code written within it. The Global.asax file is optional, if we donot define the file, the ASP.NET framework assumes that it have not defined any application or session event handlers.

Compiled By Prof. Vaibhav Vasani

Q5: Attempt any three of the following: [Ashwini] (A)disconnected data architecture of ado.net? Ans:ADO.NET supports two different programming environments: connected and disconnected. The connected environment provides forward-only, read-only access to data in the data source and the ability to execute commands against the data source. The connected classes provide a common way to work with connected data regardless of the underlying data source. They include Connection, Command, DataReader, Transaction, ParameterCollection, and Parameter classes. The disconnected environment allows data retrieved from the data source to be manipulated and later reconciled with the data source. The disconnected classes provide a common way to work with disconnected data regardless of the underlying data source. They include the DataSet, DataTable, DataColumn, DataRow, Constraint, DataRelationship, and DataView classes. Finally, ADO.NET introduces the connected DataAdapter class to bridge the data source and disconnected classes by way of the connected classes. The DataAdapter is an abstraction of the connected classes that simplifies filling the disconnected DataSet or DataTable classes with data from the data source and updating the data source to reflect any changes made to the disconnected data. Figure 1-1 shows the relationship between the connected and disconnected classes in ADO.NET. Figure 1-1. The connected and disconnected ADO.NET classes

Compiled By Prof. Vaibhav Vasani

1.2.2 Disconnected Classes The following ADO.NET classes allow data to be retrieved from the data set, examined and modified offline, and reconciled with the data source through the DataAdapter: DataSet Provides a consistent way to deal with disconnected data completely independently of the data source. The DataSet is essentially an inmemory relational database, serving as a container for the DataTable, DataColumn, DataRow, Constraint, and DataRelation objects. The XML format serializes and transports a DataSet. A DataSet can be accessed and manipulated either as XML or through the methods and properties of the DataSet interchangeably; the XmlDataDocument class represents and synchronizes the relational data within a DataSet object with the XML Document Object Model (DOM). DataTable Allows disconnected data to be examined and modified through a collection of DataColumn and DataRow classes. The DataTable allows constraints such as foreign keys and unique constraints to be defined using the Constraint class. DataColumn Corresponds to a column in a table. The DataColumn class stores metadata about the structure of the column that, together with
Compiled By Prof. Vaibhav Vasani

constraints, defines the schema of the table. The DataColumn can also create expression columns based on other columns in the table. DataRow Corresponds to a row in a table and can examine and update data in the DataTable. The DataTable exposes DataRow objects through the DataRowCollection object it contains. The DataRow caches changes made to data contained in its columns, storing both original and current values. This allows changes to be cancelled or to be later reconciled with the data source. Constraint Allows constraints to be placed on data stored within a DataTable. Unique and foreign key constraints can be created to maintain data integrity. DataRelation Provides a way to indicate a relationship between different DataTable objects within a DataSet. The DataRelation relates columns in the parent and child tables allowing navigation between the parent and child tables and referential integrity to be enforced through cascading updates and deletes. DataView Allows data, once retrieved into a DataSet or DataTable, to be viewed in different ways. It allows data to be sorted based on column values and for a subset of the data to be filtered so that only rows matching specified criteria are displayed

(b) explain post and get method and give the difference between them? Ans:A <FORM> tag can also contain an attribute describing what action to take when the form is submitted as well as a method attribute to specify how the information from the form is transmitted to the server. The method attribute can be one of two values, Post or Get. The Get method is the default; however, Get is deprecated in HTML 4 because of internationalization problems. The Post method is a twostep method (transparent to you, as the developer of the page) that sends all the information entered in a form to a standard location, where the server
Compiled By Prof. Vaibhav Vasani

reads it. The Get method appends the form contents to the URL as arguments. For example, if a form has a single text box, name, that contains the value Doug, and if the form is using the Get method and the action is a page named test.aspx, this is the resulting URL that will next appear in the browsers location window (barring any processing error): http://<host>/<directory>/test.aspx?name=Doug So which method is best to usePost or Get? As is often the case, theres no simple answer. For small forms with little data being passed back and forth, Get can be more efficient. For larger forms, some servers will break if the URL is too long, and so its often best to use Post. In addition, if youre sending a password back from the form, you should use Post so that the password wont appear in the URL as plain text. Each widget is fairly self-explanatory once youve seen the code in Listing B-1 and then the resulting browser screen, shown in Figure B-1. For the text box, Ive provided a default value for the control. In virtually all cases, the value attribute in an HTML control determines either what is initially displayed or what is returned when the widget is selected and the form is submitted. The ASP.NET controls use a more Visual Basiclike structure, so the Text property of a control maps to the HTML value attribute. Some users may not like the fact that the ASP.NET objects have properties with different names than the HTML attributes they are mapped to, but Visual Basic programmers should feel comfortable with the ASP.NET objects. Also, in the description of the list box, I wanted to display the text <SELECT>. Rather than using that literal, I used &lt;SELECT&gt;. If Id used less than and greater than symbols (< or >), <SELECT> would have been interpreted as the beginning of a list box, which isnt what I wanted. (c)Life cycle of asp.net Ans. Page_Load event. The IsPostBack property of the Page class will help us handle the two situations that well encounter on the Page_Load event. ASP.NET Web Form Stages The life cycle of an ASP.NET Web Form has five basic stages: Page_Init The ASP.NET page framework uses this event to restore control properties and postback data (data entered in controls by the user before the form was submitted). Page_Load The developer uses this event either to perform some initial processing (if this is the first visit to the page) or to restore control values (if this is a postback).
Compiled By Prof. Vaibhav Vasani

Validation The Validate method of ASP.NET server controls is called to perform validation for the controls. Other event handling Various controls expose many events. For example, the Calendar control exposes a SelectionChanged event, as well see later in this section. Theres no assurance that events will be raised in any particular order, except that cached control events (as specified in the controls AutoPostBack property) are always processed before the posting event. If the page contains validation controls, you should check the IsValid property of the page and individual validation controls to determine whether validation has been passed. Page_Unload This event is called as the page has finished rendering. This would be the place to clean up any resources allocated, especially expensive resources like file handles and database connections. Simply allowing these resources to pass out of scope might not be enough, especially on a busy site, where waiting for garbage collection to occur might hinder performance. When a page is loaded, two scenarios are possible: this could be the first time this page is loaded, or this could be a postback. In the Page_Load event handler, the following code handles the two possible page-loading scenarios: Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles MyBase.Load Put user code to initialize the page here If Page.IsPostBack = False Then Calendar1.BackColor = System.Drawing.Color.BlanchedAlmond Calendar1.ForeColor = System.Drawing.Color.Red Calendar1.TodaysDate = "7/24/2001" LinkButton1.Enabled = False TextBox1.Text = "Hello" End If End Sub In this example, processing is done only when Page.IsPostBack is false that is, the first time the page is processed, not when a form is filled in. When Page.IsPostBack is false, the page programmatically sets several properties of the Calendar control as well as the Enabled property of the link button and the Text property of the text box. For the Calendar control, the BackColor and ForeColor properties are set, along with the TodaysDate property. The TodaysDate property is used to set the controls view of what todays date is, which can be different from the system date on the server or the client. These simple examples of setting properties are just the tip of the iceberg as far as the level of programmatic control you can have over components. Q.6 : Attempt any three of the foll: [Aarti ]
Compiled By Prof. Vaibhav Vasani

a. What is the difference between content rotator and adrotator component? b. Describe the steps necessary to display the position and record count for a single record? Ans: 1. First, create the connection and adapter object by using the SqlConnection or OledbConnection class. 2. Declare the dataset object. 3. Declare and initialize the dataview Object with table. 4. Declare and define the currency manager object with Binding Context Method. 5. Use the Position property Of currency Manager to display the position Of the record. 6. Use the count property Of currency Manager to display the total number of records. Below given program demonstrate the use of above properties:-

Imports System.Data Imports System.Data.OleDb Public Class write Dim conobj As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Aarti\Student.mdb;") Dim adap As New OleDbDataAdapter("Select * from Stud ", conobj) Dim ds As DataSet Dim dv As DataView Dim cm As CurrencyManager

Compiled By Prof. Vaibhav Vasani

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load filldatasetanddataview() bindingfields() showPosition() End Sub

Private Sub filldatasetanddataview() ds = New DataSet() adap.Fill(ds, "Stud") dv = New DataView(ds.Tables("Stud")) cm = CType(Me.BindingContext(dv), CurrencyManager) End Sub Private Sub bindingfields() TextBox1.DataBindings.Clear() TextBox2.DataBindings.Clear() TextBox1.DataBindings.Add("text", dv, "Rollno") TextBox2.DataBindings.Add("text", dv, "Name") End Sub Private Sub showPosition() TextBox3.Text = cm.Position + 1 & " Of " & cm.Count() End Sub

Compiled By Prof. Vaibhav Vasani

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click cm.Position = 0 showPosition()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click cm.Position += 1 showPosition() End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click cm.Position -= 1 showPosition() End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click cm.Position = cm.Count - 1 showPosition() End Sub End Class

Compiled By Prof. Vaibhav Vasani

OUTPUT:

C. Explain the concept of methods and collections in ASP.NET with example.

D. Write a web application that will perform editing in data grid (using events of data grid example:-edit command, cancel command, update command).

Ans: Refer Experiment 12 (Group B:-Q.3)

Compiled By Prof. Vaibhav Vasani

Compiled By Prof. Vaibhav Vasani

Vous aimerez peut-être aussi