Sample 2 paper of AWT subject soluion

Embed Size (px)

Citation preview

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    1/30

    Compiled By Prof. Vaibhav Vasani

    SAMPLE PAPER 2

    Q.1 )Attempt any four of the following:

    a)What are Assemblies & Namespaces describe them.Ans.

    Assemblies:Assemblies are the building blocks of the .Net framework, they form the

    fundamental unit of deployment , version control, reuse, security permissionsand more.

    The purpose of an assembly is to specify a logical unit or building block,applications that encapsulate certain properties. Basically, the term assemblyrefers to both a logical construct and a set of physical files.

    A .Net application consist of one or more assemblies. Logically Speaking,an assembly is just a set of specifications as follows:

    1. An Assembly specifies the MSIL code that is associated with the assembly.This code lies in portable executable files.

    2. An assembly specifies security permissions for itself.3. An assembly specifies a list of data types and provides scoping for those types.

    The scoping provided by an assembly means that different types may have thesame name, as long as they belong to different assemblies and can thereforebe distinguished by means of the assembly to which they belong.

    4. An assembly specifies the rules for resolving external types and externalreferences, including references to other assemblies.

    5. An assembly specifies which of its parts are exposed outside the assembly andwhich are private to the assembly itself.

    Namespaces:

    The notion of the namespace plays a fundamental role in the .Net framework. In

    general, a namespace is a logical grouping of types for the purpose of identification.

    We cannot build a VB.Net application without using the classes from the .net

    system namespace. The .Net framework class Library(FCL), consist of several thousand

    classes and other types ( such as interfaces, structures and enumerations that are

    divided into over 90 namespaces.)

    Thus, a namespace is a collection of different classes. All VB applications are

    developed using the classes from the >net system namespace. The namespace with all

    the functionality is the system namespace. All other namespaces are based on the

    namespaces.

    Some of the namespaces are:

    System System.Collections System.configuration System.ComponentModel System.Io

    System.Text System.Text.RegularExpressions System.Web.Services System.XML

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    2/30

    Compiled By Prof. Vaibhav Vasani

    b)Describe the keywords: overridable, overrides, Non-overridable, & mustoverride with example.Ans.

    overridable, overrides, Non-overridable, & must override are the modifiersthat are to control how properties and methods are overridden.

    Overridable: Allows the property or method in a class to be overridden in aderived class.

    Overrides: Overrides an overridable property or method defined in the baseclass.

    NotOverridable: prevents a property or method from being overridden in aninheriting class. Public methods are NotOverridable by default.

    MustOverride : requires that derived class override the property or method.When the MustOverride keyword is used, the method definition consists of just

    the subFunction or property statement. No other statements are allowed andspecifically there is no End Sub statement. MustOverride methods must bedeclared in MustInherit classes.

    Example:Imports system

    Module module1

    Sub main()

    Dim o AsNew c2()

    o.show()

    Console.Read()

    EndSub

    EndModuleClass c1

    OverridableSub show()

    Console.WriteLine("show old method")

    EndSub

    EndClass

    Class c2

    Inherits c1

    PublicOverridesSub show()

    Console.WriteLine("show new and improved method")

    EndSub

    EndClass

    c)Describe 4 date & time related functions used in VB.Net with example.

    d)With example explain any 8 Meta characters used in VB.Net.Ans.

    Meta characters are the characters that have special meaning within thelanguage of regular expressions. These include the following:

    Characters Description. The dot matches any single character.

    \n Matches a newline character ( or CR+ LF combination)\t Matches a tab (ASCII 9)\d Matches a digit (0-9)\D Matches a non-digit.

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    3/30

    Compiled By Prof. Vaibhav Vasani

    \w Matches an alphanumeric character.\W Matches a non-alphanumeric character.\s Matches a whitespace character.\S Matches a non-whitespace character.\ Use \ to escape special characters. For example, \.

    Matches a dot and \\ matches backslash.

    ^ Match at the beginning of the input string.$ Match at the end of the input string.() Match a group pattern.

    Examples:

    pattern Inputs(matches)

    . a, b , c, 1, 2, 3

    .* Abc, 123, any string, even no characters would match

    ^c:\\ C:\windows

    C:\\\\\

    C:\foo.txt

    C:\followed by anything else

    abc$ abc

    123abc

    Any string ending with abc

    (abc){2,3} abcabc

    abcabcabc

    1.3 123

    1z3

    133

    1.*3 13

    123

    1zdfkj3

    \d\d 01, 02, 99, ..

    \w+@\w+ [email protected]

    a@a

    mailto:[email protected]:[email protected]:[email protected]
  • 8/2/2019 Sample 2 paper of AWT subject soluion

    4/30

    Compiled By Prof. Vaibhav Vasani

    e)Describe select case statement with example used in VB.Net.Ans.

    The select case statement executes one of several groups of statementsdepending on the value of an expression. If your code has the capability to handledifferent values of a particular variable then you can use a select case statement .you use select case to test an expression, determine which of the given cases itmatches and execute the code in that matched case.

    Syntax:Select testexpression

    Case expressionlistStatements

    Case elseElse statements

    End select

    If testexpression matches any case expressionlist clause, the statementsfollowing that case statement run up to the next case, case else or end selectstatement. Control then passes to the statement following end select.

    Example:Module Module1

    Sub Main()

    Dim s AsString

    Dim n AsInteger

    Console.WriteLine("select base language: 1= c++ 2=Java 3=vb.net")

    Console.Write("please enter your selection")s = Console.ReadLine()

    n = Integer.Parse(s)

    SelectCase n

    Case 1

    Console.WriteLine("Not bad, try again")

    Case 2

    Console.WriteLine("Not even close")

    Case 3

    Console.WriteLine("you are right, congratulations")

    CaseElse

    Console.WriteLine("invalid selection")

    EndSelect

    Console.Read()

    EndSub

    EndModule

    f)List & describe 4 advantages of DOTNET framework.Ans.

    The .Net framework offers a number of advantages to developers. They aregiven below:

    1.Consistent programming model:

    With .Net, for example, accessing the data with a VB.NET and c#.NET looksvery similar apart from slight syntactical differences. Both the programs needto

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    5/30

    Compiled By Prof. Vaibhav Vasani

    import the System.Data namespace, both the programs establish a connectionwith the database and both the programs run a query and display the data on adadagrid. This is achieve by using the .NET class library, a key component of the.NET framework.

    The functionality that the .Net class library provides is available to all .NETlanguages resulting in a consistent object model regardless of the programminglanguage the developer uses.

    2.Direct support for security:When an application accesses dada on a remote machine or has to perform

    a privileged task on behalf of a nonprivilaged user, security issue becomesimportant as the application is accessing the data from a remote machine. With.Net, t5he framework enables the developer and the system administrator tospecify method level security.

    It uses industry-standard protocols such as TCP/Ip, XML, SOAP and HTTPto facilitate distributed application communications. This makes distributedcomputiong more secure because .Net developers cooperate with network

    security devices instead of working around their security limitations.

    3.Simplified Development efforts:In web applications, a developer with classic ASP needs to present data

    from a database in a webpage. He/She has to write the application logic, (code)and presentation logic, (design) in the same file. ASP.NET and .Net frameworksimplify development by separating the application logic and presentation logicmaking it easier to maintain the code.

    The design code, (presentation logic) and the actual code(application logic)is written separately eliminating the need to mix HTML code with ASP code.ASP.NET can also handle the details of maintaining the state of the controls,such as contents in a textbox, between calls to the same ASP.NET page.

    The .Net framework simplifies the debugging with support for runtimediagnostics. Runtime diagnostics helps you to track down bugs and also helpsyou to determine how well n application performs.

    4.Cross language compatibility:Cross language compatibility means .Net components can interact with each other

    irrespective of the languages they are written in. Application written in VB.Net can

    reference a DLL file written in C# or a C# application can refer to a resource written in

    VC++, etc. The language interoperability extends to object-oriented inheritance.

    Q.2 Attempt any three of the following: [SUNIL.WADHWANI ]

    a)What is interface? How it is different from class.Write code todemonstrate use of interface.Ans: An interface is definition of methods and property.If a class agrees to

    implement an interface it must implement all of the properties and methods

    defined .

    An interface is declared using the interface keyword.

    An interface is the type with members that are all public.MustOverride is thedefault.

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    6/30

    Compiled By Prof. Vaibhav Vasani

    An interface is implemented by the class .A class implementing the interfacemust provide body for all the members of an interface.

    To implement an interface , a class uses the Implements keyword to showthat it is

    implementing a particular interface.

    An interface itself can inherit other interfaces.Difference between Class and Interface.

    1.An interface defines how a class may be implemented. An interface is not aclass and classes can only implement interfaces. When a class defines a

    function declared in an interface, the function is implemented, not

    overridden. Therefore, name lookup does not include interface members.

    2. In Interface there is no code and only the templates for the properties andmethods.

    3.A class can implement more than one interface contrary to classinheirtance where you can only inherit one class.

    4.An interface like abstract classes ,can not be instantiated where as classescan be instantiated.

    Code to Demonstrate use of Interface:Interface sample

    Sub read()Sub write()Property status() AsInteger

    EndInterface

    PublicClass DocumentImplements samplePrivate mystatus AsInteger = 0

    PublicSubNew()Console.WriteLine("Creating document")

    EndSubPublicSub read() Implements sample.read

    Console.WriteLine("Implementing the Read method.")

    EndSub

    PublicProperty status() AsIntegerImplements sample.statusGet

    Return mystatusEndGetSet(ByVal value AsInteger)

    mystatus = valueEndSet

    EndProperty

    PublicSub write() Implements sample.writeConsole.WriteLine("Implementing the Write Method.")

    EndSub

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    7/30

    Compiled By Prof. Vaibhav Vasani

    EndClass

    Module Module1

    Sub Main()Dim doc AsNew Documentdoc.status = 1doc.read()doc.write()Console.WriteLine("Document Status:" & doc.status)Console.ReadLine()

    EndSub

    EndModule

    OUTPUT:

    Creating documentImplementing the Read methodImplementing the Write MethodDocument Status:1

    b)Describe SQL data provider & OLEDB data provider & state function ofclasses available in those.Ans:SQL DataProvider:

    The SQL Server .NET data provider ships with the .NET Framework. It usesthe Tabular Data Stream (TDS) protocol to send requests to and receive

    responses from the SQL Server.

    This provider delivers very high performance because TDS is a fast protocolthat can access Microsoft SQL Server directly without an OLE DB or ODBC

    layer and without COM interop.

    The SQL Server .NET data provider can be used with Microsoft SQL Server7.0 or later. To access earlier versions of Microsoft SQL Server, the OLE DB

    .NET data provider with the SQL Server OLE DB provider (SQLOLEDB)

    should be used. The SQL Server .NET data provider classes are located in

    the System.Data.SqlClient namespace.

    When working with SQL Server the classes with which we work are described

    below are:

    The SqlConnection class:

    The sql connection class represents a connection to SQL Server data

    source .We use OleDB connection object when working with databases other

    than SQL Server. Performance is the major difference when working withSqlConnections and OleDbConnections .SQL connections are said to be 70%

    faster than Oledb connections.

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    8/30

    Compiled By Prof. Vaibhav Vasani

    The Sqlcommand class:

    The Sqlcommand class represents a SQL statement or stored procedure

    for use in a database with SQL Server.

    The SqldataAdapter:

    The SqlDataAdapter class represents a bridge between the dataset and the

    SQL Server Database.It includes the Select, Insert, Delete, and update commands

    for loading and updating the data.

    The SqlDataReader:

    The sqlDataReader class creates a data reader to be used with SQL Server.

    OLEDB DataProvider: The OLE DB .NET data provider ships with the .NET Framework. It

    communicates with a data source using a data source-specific OLE DB

    provider through COM interop.

    The OLE DB provider, in turn, communicates directly with the data sourceusing native OLE DB calls. The OLE DB .NET data provider supports OLE

    DB interfaces later than Version 2.5. As a result, some OLE DB providers,

    including those for Microsoft Exchange Server and Internet Publishing,

    aren't supported. Also, the OLE DB .NET data provider can't be used with

    the OLE DB provider for ODBC (MSDASQL).

    The OLE DB.NET data provider classes are located in theSystem.Data.OleDb namespace.

    When working with OLE DB the classes with which we work are described below

    are:

    OleDbconnection class :

    The OleDbconnection class represents a connection to OleDb datasource.Oledb connections are used to connect to most databases.

    OleDbCommand class:

    The OleDbCommand represents a SQL Statement or the stored procedure

    that is executed in a database by an OLEDB provider.

    OleDbDataAdapter class:

    The OleDbDataAdapter class acts as a middleman between the datasets

    and OleDb data source.We use the Select ,Insert, Delete,Update commands for

    loading and updating the data.

    OleDbReader class:

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    9/30

    Compiled By Prof. Vaibhav Vasani

    OleDbDataReader class creates a data reader for use with an oledb data

    provider.It is used to read a row of data from the database. The data is read as

    forward only stream which means that data is read sequentially,one row after

    another not allowing you to choose a row you want or going backwords.

    c) What is home directory ,default document,virtual directory related toASP.NETAns:

    Home Directory:

    IIS is way to share the files over the internet.Just like as sharing files inWindows over a Windows network,in IIS you need to choose a folder whosefiles are shared by default,this folder is C:\Inetpub \WWWroot\.

    In Internet Information Service dialog box,the files that are listed in theright pane are the files created in the :\Inetpub\WWWroot\directory

    during the installation of IIS.These are Simply a few HTML documents and

    related images that act as an introduction to IIS

    To access a particular file in the home directory in IE, the filename must beincluded in the url

    after the initial http://LocalHost.

    DEFAULT Document:

    If you visit http://www.microsoft.com/net,you do not get a list of files

    eitheryou are also sent an HTML page .In fact ,its very rare that an HTTP server

    will return a list of files to a user or client on the Internet,because

    It is very user-unfriendly to except a user to select the file that he orshe would like to view when he or she visits a site.

    Second, from a security perspective. To counter these issues ,IIS includes Supprot for a defult

    document.This is basically the file that IIS will return by default ifthe user request does not specify specific file to be returned .

    For example, if the default document is set to be index.htm and theuser submits a request for http://localhost, the browser will in fact

    return http://localhost/index.htm if

    It exists. IIS will attempt to return the first file in the list and if that

    does not exist,then the second file and so on.

    Virual Directories:

    A virtual directory represents a web application and it points to a physicalfolder in your computer.

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    10/30

    Compiled By Prof. Vaibhav Vasani

    A web application is accessed using a virtual directory name instead of aphysical folder name. For example, if you have a web application called

    "Shopcart" in your machine, you will have a virtual directory for this web

    application. You will access your web application using the URL

    httP://localhost/Shopcart. If your virtaul directory name is "Test", then

    your web application url will be "http://localhost/Test".

    Assume you have a web application called "Shopcart", created under thephysical folder "C:\MyProjects\Shopcart".

    You can go to IIS and see this virtual directory listed. Right click on thisvirtual directory name in IIS and see the properties. You can see that this

    virtual directory is pointing to the physical location

    "C:\MyProjects\Shopcart".

    If you have a file called "File1.aspx" under the folder"C:\MyProjects\Shopcart\", then you can access this file using Internet

    Explorer with the URL "http://localhost/Shopcart/File1.aspx"

    d)Describe constructor ,parametrized constructor ,shared member &destructor with example.Ans:

    1) Constructors are Special kind of sub procedures.A constructor has thefollowing properties:

    1. It always has the New.

    2. Being a sub procedure , it does not return any value.

    3. It is automatically called when a new instance or object of a class iscreated, hence called a constructor.

    Example:

    Imports SystemClass student

    Private n AsStringPublicSubNew()

    n = "unknown"Console.WriteLine("Constructor called...")

    EndSubPublicProperty name() AsString

    GetReturn n

    EndGetSet(ByVal value AsString)

    n = valueEndSet

    EndPropertyEndClass

    Module Module1

    Sub Main()

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    11/30

    Compiled By Prof. Vaibhav Vasani

    Dim s AsNew studentConsole.WriteLine("Name of Student:" & s.name)s.name = "abc"Console.WriteLine("Name of student:" & s.name)Console.ReadLine()

    EndSub

    End Module

    2)Parametrized Constructor:Parametrized constructrors allows you to create new instance of a class whilesimultaneously passing arguments to the new instance.Example:

    Class studentDim name AsString

    Dim roll AsInteger

    PublicSubNew(ByVal n AsString, ByVal r AsInteger)name = nroll = r

    EndSubSub display()

    Console.WriteLine("Name:" & name)Console.WriteLine("Roll:" & roll)

    EndSubEndClassModule Module1

    Sub Main()Dim s AsNew student("abc", 123)s.display()Console.ReadLine()

    EndSub

    EndModule

    3)Shared Members of the class: In visual Basic .Net ,we can use the shared data members to allow

    multiple instances of class to refer to a single class level variable.

    Use the following syntax to declare shared data members :

    AccessLevel Shared DataMember as DataType

    Shared members are directly linked to the class and you can declare themas public or private.If you declare data members as public ,they are

    accessible to any code that can access the class.

    If you declare the data members as private ,you provide public sharedproperties to access the private shared property.

    The following example shows how to create savings account class that usesa public shared data member to maintain interest rates for a savings

    account.

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    12/30

    Compiled By Prof. Vaibhav Vasani

    Example:Class SavingsAccount

    Public Shared InteresrRate As DoublePublic Function CalculateInterest() As Double.End Function

    End ClassThe value of InterestRate data member of the SavingsAccount class can be

    set globally regardless of how many instances of the class are in the use.Thisvalue is then used to calculate the interest on the current balance.

    4)Destructor

    Each class in VB.NET is automatically inherited from the object class whichcontains the method finalize().

    This method is guaranteed to be called when your object is garbagecollected.

    You can use it to clean up open resources, such as database connectionsor to release other resources .You can override this method and put here

    the code for

    freeing resources that you reserved when using the object.

    Class TestProtectedOverridesSub Finalize()

    Console.WriteLine(Destructing object.)EndSub

    EndClass

    Module Module1

    Sub Main()Dim t AsNew Test()Console.ReadLine()

    EndSub

    EndModule

    The Finalize() sub procedure is called automatically when the object is

    about to be destructed.(when garbage collector is about to destroy your object tocleanup the memory).In c++ programmers had to manage the memory allocationand de-allocation explicitly.Destructors were used there to free the memoryallocated by the object.But with VB.NET, the memory is managed autoamaticallyon behalf of your program.

    Q. 3 Attempt any three of the following:[ Chaitanya ]

    a) Describe System.web.mail namespace & System.Net.mail namespace &their purpose.

    Ans)System.Web.Mail :

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    13/30

    Compiled By Prof. Vaibhav Vasani

    1.The System.Web.Mail namespace contains classes that enable you toconstruct and send messages

    2. System.Web.Mail is not a full .NET native implementation of the SMTPprotocol. Instead, it uses the existing CDONTS and CDOSSYS dllsalready written by Microsoft for ASP.

    3. When the SmtpMail class sends the MailMesage, the SmtMail classchecks the OS version. If the version is

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    14/30

    Compiled By Prof. Vaibhav Vasani

    Imports System.Data.oledbModule Module1

    Sub Main()Dim con AsNewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Documents and Settings\USER\MyDocuments\Emp.mdb")

    Dim com AsNew OleDbCommand("Select * from Employee", con)con.Open()Dim dr As OleDbDataReader = com.ExecuteReader

    Console.WriteLine("Emp_Id" &Microsoft.VisualBasic.Constants.vbTab & "Emp_name")

    While (dr.Read)Console.WriteLine(dr(0) &Microsoft.VisualBasic.Constants.vbTab & dr(1))

    EndWhilecon.Close()Console.ReadLine()EndSub

    EndModule

    Output:Emp_Id Emp_name1 ABC2 PQR3 XYZ

    c) Describe BrowserType component of ASP.Net.Ans)

    1. BrowserType component is used in ASP but it still works onASP.Net(aspcompat=true).

    2. BrowserType object determines the type, capabilities and versionnumber of a visitor's browser. It is created as follows:

    Syntax

    3. When a browser connects to a server, a User Agent header is alsosent to the server. This header contains information about thebrowser.

    4.The BrowserType object compares the information in the header withinformation in a file on the server called "Browscap.ini".

    5. If there is a match between the browser type and version number inthe header and the information in the "Browsercap.ini" file, theBrowserType object can be used to list the properties of the matchingbrowser. If there is no match for the browser type and versionnumber in the Browscap.ini file, it will set every property to

    "UNKNOWN".

    Example :

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    15/30

    Compiled By Prof. Vaibhav Vasani

    Client OSWeb BrowserBrowser versionFrame support?Table support?

    Sound support?Cookies support?VBScript support?JavaScript support?

    Output:

    Client OS WinNT

    Web Browser IE

    Browser version 5.0

    Frame support? True

    Table support? TrueSound support? True

    Cookies support? True

    VBScript support? True

    JavaScript support? True

    d) Describe DataView with example. List methods of DataView.Ans)

    o We can use DataView to get a snapshot of the data in a table.DataViews are much like read only mini-datasets in which you canload only a subset of a dataset.

    o DataView provide three key features :

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    16/30

    Compiled By Prof. Vaibhav Vasani

    Sorting based on any column criteria Filtering based on any combination of column values Filtering based on the row state (such as deleted, inserted, and

    unchanged)

    o When creating a DataView object, you specify the underlyingDataTable in the constructor:

    // Create a new DataView for the Customers table.DataView view = new DataView(ds.Tables["Customers"]);

    o Every DataTable also provides a default DataView through theDataTable.DefaultView property:

    // Obtain a reference to the default DataView for the Customerstable.

    DataView view = ds.Tables["Customers"].DefaultView;

    o After creating DataView object, it can be bound to DataGridViewcontrol for displaying the contents of view.

    Following Application demonstrates the use ofDataView:

    Imports System.Data.oledbPublicClass Form1

    PrivateSub Form1_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load

    Dim con AsNewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Documents and Settings\itcl4.ITSERVER\MyDocuments\Student1.mdb")

    Dim adap AsNew OleDbDataAdapter("select * from StudInfo", con)Dim ds AsNew DataSet()

    Dim dv As DataViewadap.Fill(ds, "StudInfo")dv = New DataView(ds.Tables("StudInfo"))

    DataGridView1.DataSource = dvEnd Sub

    EndClass

    OUTPUT :

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    17/30

    Compiled By Prof. Vaibhav Vasani

    Methods Of DataView Class:

    o AddNewInserts a new row into the underlying DataTable andreturns a DataRowView object that represents the new row.

    o Delete - Removes a row at the specified index. This affects both theDataView and the underlying DataTable.

    o Find - Returns the index of a single matching row, using the currentDataView sort order.

    o FindRows - Returns an array with every DataRowView object thatmatches a specified search expression in a given DataView.

    Q4) Attempt any four of the following: [ Gulshan ]

    a)List and Describe different file extension used in VB.Net.Ans.

    When you save a solution its given the file extension .sln and all theprojected in the solution are saved with the extension .vbproj.Heres a list of thetypes of the extensions you will see in the files in the VB.Net. These are asfollows:

    .vb: Can be a basic window form, a code file, a module file for storingfunctions, a user control, a data form, a custom control, an inheritedform, a web custom control, an inherited user control, a windowsservice, a custom setup file, an image file for creating a custom icon oran assembly info file.

    .xsd: An XML schema provided to create type datasets. .xml: An XML document file. .htm: An HTML document. .txt: A text file. .xslt: An XSLT style-sheet file, used to transform XML documents and

    XML Schemas. .css: A cascading style-sheet file. .rpt: A crystal report. .bmp: A bitmap file. .js: A Jscript file. .vbp: A VBScript file. .wsf: A window scripting file. .aspx: A web form. .asp: An active server page. .web: A web configuration file. .asax: A global application class, used to handle global ASP.NET

    application level events. .resx: A resource file used to store resource information. .config: Application configuration files contain settings specific to an

    application.

    b)Write a code to insert data in book.mdb table using AddWithValuecollection of command object.Ans.

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    18/30

    Compiled By Prof. Vaibhav Vasani

    Imports System.Data.OleDbImports System.DataPublic Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click

    Dim conobj As NewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Users\Gulshan\Documents\Book.mdb")

    Dim com As New OleDbCommand("insert into StudValues(@srno,@name,@price)", conobj)

    com.Parameters.AddWithValue("@srno", TextBox1.Text)com.Parameters.AddWithValue("@name", TextBox2.Text)com.Parameters.AddWithValue("@price", TextBox3.Text)conobj.Open()com.ExecuteNonQuery()conobj.Close()

    End Sub

    Private Sub Button2_Click(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles Button2.Click

    TextBox1.Clear()TextBox2.Clear()TextBox3.Clear()

    End SubEnd Class

    c)Describe 2 methods & properties of session object.Ans.Properties:

    i) Session.TimeOut Property:The Session.TimeOut Property can be used to set the expiration time

    in minutes for the session. If the user does not refresh the page orrequest another page within the allotted time, the session isautomatically terminated and the resources are released. The default is20 minutes. This property is mostly used in many online bankingsystems, to avoid misusages.

    Eg. Response.Write(Default Timeout is: & Session.Timeout)

    ii) Session.CodePage Property:The Session.CodePage Property can be used to specify how strings

    are encode on a page. A codepage is simply a set of characters. Thedefault value of the CodePage varies by location and language. Forexample, the language Hindi or Gujarati uses another characters thanEnglish or German. The Session.CodePage property affects the completeall responses in a page.

    Setting response.codepage explicitly affects a single page while

    session.codepage affects all responses in session.Eg. Response.Write(Current code page is: & Session.CodePage)

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    19/30

    Compiled By Prof. Vaibhav Vasani

    Methods:

    i) Session.Contents.RemoveAll():The Session.Contents.RemoveAll() or Session.RemoveAll()

    used to remove all items from a session object. It does not take anyparameters or return anything.Eg. Session(Rollno)=1

    Session(Name)=ABCSession.Contents.RemoveAll()

    ii)Session.Contents.Remove(name| index):The Session.Contents.Remove() method or Session.Remove()

    can be used to remove specific items from a session object. Youcan either pass the name of the item or the index of the item.When an integer is passed as a parameter then all other items inthe list will be automatically updated and it is recommended topass always the name as a parameter.Eg. Session.Contents.Remove(Rollno)

    d)Describe the purpose of Repeater control with example.Ans.

    The Repeater control displays data items in a repeating list. Similar toDataList, the content and layout of list items in Repeater is defined usingtemplates. At a minimum, every Repeater must define an ItemTemplate;Unlike DataList, Repeater has no built-in layout or styles. You must explicitlydeclare all HTML layout, formatting and style tags within the templates of thecontrol.

    Untitled Page

    Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)HandlesMe.Load

    Dim conobj As NewSqlConnection(Server=localhost;UID=sa;PWD=sa;database=Northwind)

    Dim com As New SqlCommand(Select * from Employee,conobj)Dim dr As SqlDataReaderconobj.open()dr=com.ExecuteReader()rptEmployees.DataSource=drrptEmployees.DataBind()dr.Close()

    conobj.close()End Sub

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    20/30

    Compiled By Prof. Vaibhav Vasani

    e) Write ASP.NET Code to display context of student talbe assume tale iscreated in SQL dbms system.

    Ans.

    Untitled Page

    Public Sub ButtonClicked(ByVal sender As Object, ByVal e As EventArgs)Dim conobj As New

    SqlConnection("Server=localhost;UID=sa;PWD=sa;database=Student")Dim ds As New DataSet()Dim adap As New SqlDataAdapter("Select * from Student", conobj)Dim dv As DataViewadap.Fill(ds, "Student")dv = New DataView(ds.Tables("Student"))DataGrid1.DataSource = dv

    End Sub

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    21/30

    Compiled By Prof. Vaibhav Vasani

    Q5. Attempt any four: [ Rohit ]A) List and describe form view,gridview ,detail view& state differencebetween them.Ans: Form View Control:

    It is a data bound user interface control that renders as single record at atime from its associated data source,optionally providing paging buttons to

    navigate between records.

    Binding to data source controls,such as SqlDataSource andObjectDataSource.

    The features of Form View control are as follows: Built in inserting,updating and deleting capabilities. Built in paging capabilities Customizable appearance through user defined templates ,themes

    and styles.

    Grid View:

    The Grid view control displays data as a table and provides the capabilityto sort columns, page through data, and edit or delete a single record.

    The features of grid view control are as follows: Binding to data source controls,such as SqlDataSource Built in sorting,updating,deleting,paging capabilities Built in row selection capabilities Multiple key fields Multiple data fields for the hyperlink columns Customizable appearance through themes and styles

    Detail View:

    It is a data bound usr interface control that renders a single record at atime from its associated data source,optionally providing paging buttons tonavigate between records.

    It is similar to the form view of a Access database and is typically used forupdating and /or inserting new records.

    Difference;

    1.The difference between the form view and the detail view is that theDetailsView control uses a table-based layout where each field of the data

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    22/30

    Compiled By Prof. Vaibhav Vasani

    record is displayed as a row in the control. In contrast, the FormViewcontrol does not specify a pre-defined layout for displaying a record.

    2. FormView is a data-bound user interface control that renders a singlerecord at a time from its associated data source, optionally providingpaging buttons to navigate between records. It is similar to the DetailsViewcontrol, except that it requires the user to define the rendering of each itemusing templates, instead of using data control fields.

    The main difference between DetailsView and FormView is that DetailsViewhas a built-in tabular rendering, whereas FormView requires a user-defined template for its rendering. The FormView and DetailsView objectmodel are very similar otherwise.

    b)Write code to create data table in asp.net.

    Ans:

    //Default.aspx.vb

    Imports System.Data.OleDbImports System.DataPartialClass _Default

    Inherits System.Web.UI.PageDim table AsNew DataTableDim column As DataColumnDim row As DataRowProtectedSub Page_Load(ByVal sender AsObject, ByVal e As

    System.EventArgs) HandlesMe.Loadcolumn = New DataColumncolumn.DataType = System.Type.GetType("System.Int32")column.ColumnName = "id"table.Columns.Add(column)

    column = New DataColumncolumn.DataType = System.Type.GetType("System.String")column.ColumnName = "item"table.Columns.Add(column)

    Dim i AsIntegerFor i = 0To 10

    row = table.NewRowrow("id") = irow("item") = "item" & itable.Rows.Add(row)

    NextGridView1.DataSource = tableGridView1.DataBind()

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    23/30

    Compiled By Prof. Vaibhav Vasani

    EndSubEndClass

    //Default.aspx

    Qb

    c)Describe inheritance modifiers like Inherits,Not Inheritable,Must inheritwith example.

    Ans:

    Visual basic introduces the following class level statements and modifiers tosupport inheritance:

    Inherits Statement:specifies the base class NotInheritable modifier:prevents programmers from using the class as a

    base class MustInherit modifier:specifies that the class is intended for use as a base

    class only.instances of MustInherit classes cannot be created directly;theyca only be created as base class instances of a derived class.

    Inherits

    we use the Inherits keyword to define a derived class that will inherit from anexisting base class.

    Example of Inherits Keyword:

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    24/30

    Compiled By Prof. Vaibhav Vasani

    Public class CheckingAccount

    Inherits BankAccount

    Private sub ProcessCheck()

    Add code to process a check drawn on this account

    End sub

    End class

    NotInheritable

    NotInheritable keyword define a class that cannot be used as a base class forinheritance.A compiler error is generated if another class attempts to inherit fromthis class.

    Example:

    Public NotInheritable class TestClass

    .

    End class

    Public class Derivedclass

    The following line generates a compiler error

    Inherits TestClass

    ..

    End class

    MustInherit

    MustInherit keyword define classes that are not intended to be used directly asinstantiated objects. The resulting class must be inherited as a base class for usein an instantiated derived class object.

    Example:

    Public MustInherit class BaseClass

    ..

    End class

    If the client code attempts to create an instance of this type of class a compilererror is generated.

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    25/30

    Compiled By Prof. Vaibhav Vasani

    d)What are server variables? write code to display all server variables withtheir values on IE.

    Ans:

    Server Variables:

    Server variables are the predefined environmental variables which give theadditional information related to the application.

    Some examples of server variables are:

    REMOTE_ADDR, REMOTE_HOST, SERVER_PORT, SERVER_PROTOCOL,SERVER_SOFTWARE

    Request.serverVariables property:

    The request.ServerVariables property can be used to retrieve informationabout the predefined server variables.

    //program

    Experiment 9

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    26/30

    Compiled By Prof. Vaibhav Vasani

    e)Describe Get and Post method? State difference between them.

    Ans:

    GETis simply the method in which the browser compiles a URL.A typicalURL in this context will consist of a protocol, for example, HTTP for hypertext orFTP for file transfer, a fully qualified domain name, such aswww.aspalliance.com,followed by a path, such as /chrisg/, and then the page to GET, such asdefault.asp or index.html.You can add information as parameters, called aquerystring.

    When a browser sends information using the POSTmethod, the parametersare compiled in the same way but sent separately in the HTTP header, and so arenot seen in the URL portion of the browser like GETrequests are. Forms oftenuse POSTfor this very reason.

    Get-> we can transfer limited data and its not secure.post-> we can transfer unlimited data. ans its a secure.

    Q:6) Attempt any four: [ Janu ]

    A) Describe structure of ASP.Net page

    Ans.

    Structure of ASP.Net page:

    ASP.Net page consists of the following page elements

    1. Directives.

    2. Code Declaration Block

    3. Code Render block

    4. ASP.Net Controls

    5. Server side comments

    6. Server side include directives.

    Directives :-

    Directives control the compilation of an ASP.Net page. The beginning of a

    directive is marked with the characters character.

    This is shown in line 1 of the example above. A directive can appear anywhere in

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    27/30

    Compiled By Prof. Vaibhav Vasani

    the page but by convention, a directive appears typically at the top of an ASP.Net

    page. There are two types of directives:

    a) Page Directives :

    This directive appears on the top of an ASP.Net page. It specifies which

    programming language is being used to write an ASP.Net page. For

    example, if we Want to use VB as our page language, we will use the

    following directive:

    b) Import Directives :

    By default, only certain namespaces are automatically imported into an

    ASP.Net page. If you want to refer to a class that is not a member of one of

    the default namespaces, then you must explicitly import the namespace of

    the class or you must use the fully qualified name of the class.%@Import Namespace = System.Web.Mail%

    This line imports all of the classes of the System.Web.Mail namespace, tosend the mail through the SmtpMail class.

    Code Declaration Block :-

    It contains all the application logic for your ASP.Net page & all the global

    variable declarations, subroutines & functions. It must appear within a

    tag.

    Code Render Block :-

    If you need to execute code within the HTML or text content of yourASP.Net page, you can do so within the code render blocks. The two types of

    Code Render Blocks are:

    i) Inline code: It executes a statement or series of statements. This type of

    code begins with the characters

    ii) Inline Expressions: It begins with the characters

    Code Render Block contains additional instructions that ASP.Net pages uses toproduce output.

    ASP.Net Controls :-

    ASP.Net controls can be freely interspersed with the text of HTML content

    of a page. The only requirement is that the control should appear within the

    tag.

    One significant limitation of ASP.Net page is that it contains only one tag. This means you cant group ASP.Net into multiple forms

    on a page. And if you try this you will get an error.

    Server Side Comments :-

    mailto:%25@Import%20Namespace%20=%20%E2%80%9CSystem.Web.Mail%E2%80%9D%25mailto:%25@Import%20Namespace%20=%20%E2%80%9CSystem.Web.Mail%E2%80%9D%25mailto:%25@Import%20Namespace%20=%20%E2%80%9CSystem.Web.Mail%E2%80%9D%25
  • 8/2/2019 Sample 2 paper of AWT subject soluion

    28/30

    Compiled By Prof. Vaibhav Vasani

    To add comments to your ASP.Net pages one can use server side comments

    blocks. The beginning of the comment is marked with the characters . It can be added to the ASP.Net pages for the purpose of

    documentation.

    Server Side Include Directives :-

    You can include a file in an ASP.Net page by using one of the two forms of

    the serversode include directives. If you want to include a file that is located in

    the same directory or in a subdirectory of the page including the file, you can use

    the following directive :

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    29/30

    Compiled By Prof. Vaibhav Vasani

    Syntax:

    4)RegularExpressionValidator

    Ensures that value of an input control matches a specified pattern..

    Syntax:

    5)RequiredFieldValidator

    Makes an i/p control a required field.

    Syntax:

    6)ValidaionSummary

    Displays a report of all validation errors occured in a web page.

    Syntax:

    d) List & describe different Data set method for XML processing.

    Ans:

    The DataSet object is stored in memory in a binary format just like

    any other .NET object. It is always remoted and serialized in a special XMLformat called the DiffGram. A Dataset is a basket that stores data obtained

    from data source. This data source can also be XML document. There may

    be different type of dataset typed or untyped.

    A typed dataset consists of XML schema. But untyped dataset does not

    have this type of schema in it.

    The XML schema contains whole information about the relation

    structure. It contains information about the relation structure. It contains

    information regarding table, constraints and relation. The table below

    presents the Dataset's method you can use to work with XML, both inreading and in writing.

  • 8/2/2019 Sample 2 paper of AWT subject soluion

    30/30

    Methods:

    1.ReadXml

    2.WriteXml

    3.WriteXmlSchema

    4.ReadXmlSchema

    5.GetXml

    6.GetXmlSchena

    ReadXML:

    It is a method used to fill a Dataset with a data from XML.It can read data

    from a file, a stream or an XmlReader and takes as arguements the source

    of XMLReadMode argument.

    Syntax:

    public XmlReadMode ReadXml(String XmlReadMode);

    WriteXML

    It is a method used to write the XML,representation of the DataSet into a

    file.a stream an XmlWriter object or a string.The XML representation can

    include or not ionclude,schema information.The actual behavior of the

    behavior of the WriteXml method can be controlled through the optional

    XmlWriteMode parameter.

    Syntax:public XmlWriteMode WriteXml(String,XmlWriteMode);

    WriteXmlSchema:

    It is a method to create a schema of XML file..

    ReadXMLSchema:

    Reads the XML schema into the DataSet.