winter(09) paper of awt subject soluion

Upload: vaibhav-vasani

Post on 05-Apr-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    1/23

    Compiled By Prof. Vaibhav Vasani

    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 compiledlanguage.

    - 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 withspecialized VB library as a standard library.

    - VB used ASP to develop web applications, whereas VB.NET usesASP.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 documentselectronically. It is defined in the XML 1.0 Specification produced by the W3Cand 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 Solution1. Right clicking on Solution in Solution Explorer2. Click on Add new item3. Then select XMLFile.xml From window which is displayed

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    2/23

    Compiled By Prof. Vaibhav Vasani

    4. Then XML file is added in project

    XML DeclarationXML documents may begin by declaring some information about them,as in the following example.

    Example

    Here is a small, complete XML document, which uses all of these constructsand concepts.

    ABC11

    PQR22

    2. Differentiate between ASP and ASP.NETA. The difference between ASP and ASP.NET are as follows.

    - Compiled EnvironmentASP 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 frameworkASP.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

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    3/23

    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 ManagementASP provides a special collection object where the programmercould store variables pertaining to a particular visitors session.

    - User Input ValidationASP.NET provides a set of server controls that checks the

    information that user have entered is in the correct form.

    - Caching ServicesASP.NET offers two primary caching techniques. Data caching and

    Output caching.

    - SecurityIn 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 TracingASP.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 applicationperformance 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. Int64Short 2 System. Int16

    Single 4 System.Single

    String Varies System.String

    Date 8 System.Date

    Boolean 2 System.Boolean

    Object 4 System.Object

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    4/23

    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 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.

    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 ]

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    5/23

    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 onething, 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.

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    6/23

    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(thekey) 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.

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    7/23

    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:

    Untitled Page

    DATAGRID INFORMATION

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    8/23

    Compiled By Prof. Vaibhav Vasani

    OUTPUT:-

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    9/23

    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 atable. 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:-

    Untitled Page

    ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As

    System.EventArgs) HandlesMe.Load

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    10/23

    Compiled By Prof. Vaibhav Vasani

    Dim con AsNew

    OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data

    Source=E:\Employee.mdb;")

    Dim cmd AsNew OleDbCommand("select * from emp", con)

    con.Open()

    DataGrid1.DataSource = cmd.ExecuteReader

    DataGrid1.DataBind()

    con.Close()

    EndSub

    OUTPUT:-

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    11/23

    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:-

    Untitled Page

    Welcome To world Of ASP.NET Technology

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    12/23

    Compiled By Prof. Vaibhav Vasani

    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.

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    13/23

    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 theASP.NET Application.

    It is a file used to control session and application events for anapplication.

    Each application can have only one global.asax file attached to it. This file is automatically processed when an application starts andstops. 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 codewritten 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.

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    14/23

    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 anddisconnected.

    The connectedenvironment provides forward-only, read-only access to data inthe data source and the ability to execute commands against the data source.The connected classes provide a common way to work with connected dataregardless of the underlying data source. They include Connection, Command,DataReader, Transaction, ParameterCollection, and Parameter classes.

    The disconnectedenvironment allows data retrieved from the data source to bemanipulated and later reconciled with the data source. The disconnectedclasses provide a common way to work with disconnected data regardless ofthe 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 thedata source and disconnected classes by way of the connected classes. TheDataAdapter is an abstraction of the connected classes that simplifies fillingthe disconnected DataSet or DataTable classes with data from the data source

    and updating the data source to reflect any changes made to the disconnecteddata.Figure 1-1shows the relationship between the connected anddisconnected classes in ADO.NET.

    Figure 1-1. The connected and disconnected ADO.NET classes

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    15/23

    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 theDataAdapter:

    DataSet

    Provides a consistent way to deal with disconnected data completelyindependently of the data source. The DataSet is essentially an in-memory 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 beaccessed and manipulated either as XML or through the methods andproperties of the DataSet interchangeably; the XmlDataDocument classrepresents and synchronizes the relational data within a DataSet objectwith 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 allowsconstraints such as foreign keys and unique constraints to be definedusing the Constraint class.

    DataColumn

    Corresponds to a column in a table. The DataColumn class storesmetadata about the structure of the column that, together with

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    16/23

    Compiled By Prof. Vaibhav Vasani

    constraints, defines the schema of the table. The DataColumn can alsocreate expression columns based on other columns in the table.

    DataRow

    Corresponds to a row in a table and can examine and update data in theDataTable. The DataTable exposes DataRow objects through theDataRowCollection object it contains. The DataRow caches changesmade to data contained in its columns, storing both original and currentvalues. This allows changes to be cancelled or to be later reconciled withthe 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 DataTableobjects within a DataSet. The DataRelation relates columns in the parentand child tables allowing navigation between the parent and child tablesand referential integrity to be enforced through cascading updates anddeletes.

    DataView

    Allows data, once retrieved into a DataSet or DataTable, to be viewed indifferent ways. It allows data to be sorted based on column values andfor a subset of the data to be filtered so that only rows matching specifiedcriteria are displayed

    (b) explain post and get method and give the difference between them?

    Ans:-

    A tagcan also contain an attribute describing what actionto take when the form issubmitted as well as a methodattribute to specify how the information from theform is transmitted to the server. The method attribute can be one of twovalues, Postor Get. The Getmethod is the default; however, Getis deprecatedin HTML 4 because of internationalization problems. The Postmethod is a two-step method (transparent to you, as the developer of the page) that sends allthe information entered in a form to a standard location, where the server

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    17/23

    Compiled By Prof. Vaibhav Vasani

    reads it. The Getmethod appends the form contents to the URL as arguments.For example, if a form has a single text box, name, that contains the valueDoug, and if the form is using the Getmethod and the action is a page namedtest.aspx, this is the resulting URL that will next appear in the browserslocation window (barring any processing error):

    http:////test.aspx?name=Doug

    So which method is best to usePostor Get? As is often the case, theres nosimple answer. For small forms with little data being passed back and forth,Getcan be more efficient. For larger forms, some servers will break if the URLis too long, and so its often best to use Post. In addition, if youre sending apassword back from the form, you should use Postso that the password wontappear in the URL as plain text. Each widget is fairly self-explanatory onceyouve 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 valueattribute in an HTML controldetermines either what is initially displayed or what is returned when thewidget is selected and the form is submitted. The ASP.NET controls use a moreVisual Basiclike structure, so the Textproperty of a control maps to the HTMLvalueattribute. Some users may not like the fact that the ASP.NET objectshave properties with different names than the HTML attributes they aremapped to, but Visual Basic programmers should feel comfortable with theASP.NET objects. Also, in the description of the list box, I wanted to display thetext . Rather than using that literal, I used . If Idused less than and greater than symbols (< or >), would have beeninterpreted as the beginning of a list box, which isnt what I wanted.

    (c)Life cycle of asp.net

    Ans.

    Page_Load event. The IsPostBackproperty of the Pageclass will help ushandle the two situations that well encounter on the Page_Loadevent.ASP.NET Web Form Stages

    The life cycle of an ASP.NET Web Form has five basic stages:

    Page_InitThe ASP.NET page framework uses this event to restore controlproperties and postback data (data entered in controls by the user before theform was submitted).

    Page_LoadThe developer uses this event either to perform some initialprocessing (if this is the first visit to the page) or to restore control values (ifthis is a postback).

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    18/23

    Compiled By Prof. Vaibhav Vasani

    ValidationThe Validatemethod of ASP.NET server controls is called to performvalidation for the controls.Other event handling Various controls expose many events. For example, theCalendarcontrol exposes a SelectionChangedevent, 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 controlsAutoPostBackproperty) are always processed before the posting event. If the page containsvalidation controls, you should check the IsValidproperty of the page andindividual validation controls to determine whether validation has beenpassed.Page_UnloadThis event is called as the page has finished rendering. Thiswould be the place to clean up any resources allocated, especially expensiveresources like file handles and database connections. Simply allowing theseresources 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 timethis page is loaded, or this could be a postback. In the Page_Loadeventhandler, 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.LoadPut user code to initialize the page hereIf Page.IsPostBack = False ThenCalendar1.BackColor = System.Drawing.Color.BlanchedAlmondCalendar1.ForeColor = System.Drawing.Color.Red

    Calendar1.TodaysDate = "7/24/2001"LinkButton1.Enabled = FalseTextBox1.Text = "Hello"End IfEnd Sub

    In this example, processing is done only when Page.IsPostBackisfalsethat is, the first time the page is processed, not when a form is filled in. WhenPage.IsPostBackisfalse, the page programmatically sets several properties ofthe Calendarcontrol as well as the Enabledproperty of the link button and theTextproperty of the text box. For the Calendarcontrol, the BackColorandForeColorproperties are set, along with the TodaysDateproperty. TheTodaysDateproperty 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. Thesesimple examples of setting properties are just the tip of the iceberg as far as thelevel of programmatic control you can have over components.

    Q.6 : Attempt any three of the foll: [Aarti ]

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    19/23

    Compiled By Prof. Vaibhav Vasani

    a. What is the difference between content rotator and adrotatorcomponent?

    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

    PublicClass write

    Dim conobj AsNew

    OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data

    Source=c:\Aarti\Student.mdb;")

    Dim adap AsNew OleDbDataAdapter("Select * from Stud ", conobj)

    Dim ds As DataSet

    Dim dv As DataView

    Dim cm As CurrencyManager

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    20/23

    Compiled By Prof. Vaibhav Vasani

    PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As

    System.EventArgs) HandlesMyBase.Load

    filldatasetanddataview()

    bindingfields()

    showPosition()

    EndSub

    PrivateSub filldatasetanddataview()

    ds = New DataSet()

    adap.Fill(ds, "Stud")

    dv = New DataView(ds.Tables("Stud"))

    cm = CType(Me.BindingContext(dv), CurrencyManager)

    EndSub

    PrivateSub bindingfields()

    TextBox1.DataBindings.Clear()

    TextBox2.DataBindings.Clear()

    TextBox1.DataBindings.Add("text", dv, "Rollno")

    TextBox2.DataBindings.Add("text", dv, "Name")

    EndSub

    PrivateSub showPosition()

    TextBox3.Text = cm.Position + 1 & " Of " & cm.Count()

    EndSub

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    21/23

    Compiled By Prof. Vaibhav Vasani

    PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    cm.Position = 0

    showPosition()

    EndSub

    PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As

    System.EventArgs) Handles Button2.Click

    cm.Position += 1

    showPosition()

    EndSub

    PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As

    System.EventArgs) Handles Button3.Click

    cm.Position -= 1

    showPosition()

    EndSub

    PrivateSub Button4_Click(ByVal sender As System.Object, ByVal e As

    System.EventArgs) Handles Button4.Click

    cm.Position = cm.Count - 1

    showPosition()

    EndSub

    EndClass

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    22/23

    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)

  • 8/2/2019 Winter(09) paper of AWT subject soluion

    23/23

    Compiled By Prof Vaibhav Vasani