Vous êtes sur la page 1sur 48

RATHNAVEL SUBRAMANIAM COLLEGE OF ARTS AND SCIENCE, (AUTONOMOUS),

SULUR

CLASS: B.COM (CA) 2013 BATCH

SUBJECT: WEB TECHNOLOGY

UNIT I

1. Print the output for the following expression using arithmetic rules:
4*(80/4) +50-38+3^3-(4*50)
STEP 1 : 3^3 =27
STEP 2 : 80/4=20
STEP 3 : 4*50 = 200
STEP 4: 4*20 =80
STEP 5 : 80 +50-38+27-200
STEP 6 : 130-38+27-200
STEP 7 : 92+27-200
STEP 8 : 119-200
STEP 9 :-81

2. Sketch out the visual studio.NET windows.

Toolbox Window

The Toolbox window contains all the controls you can use to build your applications interface.
This window is usually retracted, and you must move the pointer over it to view the Toolbox.
The controls in the Toolbox are organized in various tabs, so take a look at them to become
familiar with the controls and their functions.

The Common Controls tab contains the icons of the most common Windows controls. The Data
tab contains the icons of the objects you will use to build data-driven applications (theyre
explored later in this tutorial). The Dialogs tab contains controls for implementing the common
dialog controls, which are so common in Windows interfaces; theyre discussed in Chapter,
More Windows Controls.
Solution Explorer Window

The Solution Explorer window contains a list of the items in the current solution. A solution can
contain multiple projects, and each project can contain multiple items. The Solution Explorer
displays a hierarchical list of all the components, organized by project. You can right-click any
component of the project and choose Properties in the context menu to see the selected
components properties in the Properties window. If you select a project, you will see the Project
Properties dialog box.

Properties Window

This window (also known as the Properties Browser) displays all the properties of the selected
component and its settings. Every time you place a control on a form, you switch to this window
to adjust the appearance of the control. You have already seen how to manipulate the properties
of a control through the Properties window.

Many properties are set to a single value, such as a number or a string. If the possible settings of
a property are relatively few, theyre displayed as meaningful constants in a drop-down list.
Other properties are set through a more elaborate interface. Color properties, for example, are set
from within a Color dialog box thats displayed right in the Properties window. Font properties
are set through the usual Font dialog box. Collections are set in a Collection Editor dialog box, in
which you can enter one string for each item of the collection, as you did for the items of the
Combo Box control earlier in this chapter.

3. Develop a vb.net program for the following output using dialog box:
Module mod DISPLAYMSG

Sub main ()

Message box. Show (Welcome to Microsoft Visual Basic)

End sub

4. Draw and explain the Tool bar Commands that required to build an application.

TextBox

It represents a Windows text box control.


Label

It represents a standard Windows label.


Button

It represents a Windows button control.


List Box

It represents a Windows control to display a list of items.


Combo Box

It represents a Windows combo box control.


Radio Button

It enables the user to select a single option from a group of choices when paired with other
RadioButton controls.
Checkbox

It represents a Windows CheckBox.


Picture Box

It represents a Windows picture box control for displaying an image.


Progress Bar

It represents a Windows progress bar control.


ScrollBar

It Implements the basic functionality of a scroll bar control.

5. Construct the truth table for AND & OR logical operators in vb.Net.
AND gate

The AND gate is an electronic circuit that gives a high output (1) only if all its inputs are
high. A dot (.) is used to show the AND operation i.e. A.B. Bear in mind that this dot is
sometimes omitted i.e. AB

OR gate

The OR gate is an electronic circuit that gives a high output (1) if one or more of its
inputs are high. A plus (+) is used to show the OR operation.
SECTION C

1. Create a program using bitwise / logical operators.


ANSWER:

Sub Main ()

Dim a As Boolean = True

Dim b As Boolean = True

Dim c As Integer = 5

Dim d As Integer = 20

'logical And, Or and Xor Checking

If (a And b) Then

Console.WriteLine("Line 1 - Condition is true")

End If

If (a Or b) Then

Console.WriteLine("Line 2 - Condition is true")

End If

If (a Xor b) Then

Console.WriteLine("Line 3 - Condition is true")

End If

If (c And d) Then

Console.WriteLine("Line 4 - Condition is true")

End If

If (c Or d) Then

Console.WriteLine("Line 5 - Condition is true")

End If

If (c Or d) Then
Console.WriteLine("Line 6 - Condition is true")

End If

If (a AndAlso b) Then

Console.WriteLine("Line 7 - Condition is true")

End If

If (a OrElse b) Then

Console.WriteLine("Line 8 - Condition is true")

End If

a = False

b = True

If (a And b) Then

Console.WriteLine("Line 9 - Condition is true")

Else

Console.WriteLine("Line 9 - Condition is not true")

End If

If (Not (a And b)) Then

Console.WriteLine("Line 10 - Condition is true")

End If

Console.ReadLine()

End Sub

End Module
2. Develop a program using relational operator for the following condition, a value is 21 ,
b value is 10.

ANSWER:

Dim a as integer=21

Dim b as integer =10

If(a=b) then

Console.writeline(a is eqal to b)

Else

Console.writeline (a is not equal to b)

End if

If(a<b) then

Console.writeline(a is less then b)Else

Console.writeline ( a is not less then b)

End if

If(a>b) hen

Console.write line (a is greater then b)

Else

Console.write line(a is not grater then b)

End if

If(a<=b) then

Console .write line (a is either less then b or equal to b)

End if

If (a>=b) then

Console. Write line(a is either greater then b or equal to b)


End if

3. Draw the sample form design using toolbox in vb.net


4. Sketch out the VB.NET IDE window.33333333

5. Write the coding for the following output using arithmetic operator:
Public Function Main() As Integer
Dim BMI as Integer
Dim Height, weight As Double
Height = text1.text
Weight = text2.text

BMI = Height / weight

End Function
UNIT II

SECTION - B

1. Find the error in the following program?

a)sub general()

Console. Writeline (inside producer general )

Subgeneral 2()

Console. Writeline (inside producer genrall2)

End sub

End sub

b) Function sub (by val x as integer,by val y as integer)

Dim result as integer

Result x+y

End function

c) Subproduct ()

Dim as integer =6

Dim b as integer=5

Dim result as integer =a*b

console.writeline (result is $result)

return result

end sub

d)function sum (by val value as integer)

if value= then

return 0

else

value.sum(value-1)
end if

end function

Answer

a)sub general ()

console.write line(inside producers genral/)

end sub

sub general 2()

console.write line(inside producers genral 2)

end sub

b)function sum(by val x as integer,by val y as integer as integer

dim result as integer

return x+y

end function

c)sub producet()

dim a as integer=6

dim b as integer =5

dim result as integer =a*b

console.write line(result is $result)

end sub

d)function sum (by val value as integer)

if value = 0 then

return 0

else

end if
end function

2. Build a program to find the square values of the integer from 1-10 using function
procedure.
ANSWER:
module mod squre
sub main()
dim I as integer
console. Write line (numbers $vb tab $square)
for i=1 to 10
console.write line (I $vb tab$ square (i))
next
end sub
function. square(by val y as integer )as integer
retry y^2
end function
end module

output
number squre
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
3. Develop a program using vb.net for the following output.

Element value

0 19

1 13

2 15
3 7
4 11
5 9
6 13
7 5

8 17

9 1

ANSWER:

modal mod histogram

sub main()

dim output as string

dim I,j as integer

dim array as integer ()=new integer (){19,13,15,7,11,9,13,5,17,1}

output&=i&ubtabe value

for i=0 to array 1.get upper bound (0)

output &=i&ubtab&array(i)

for j=1` to array (i)

next

end sub

end module

4. How to differentiate the passing parameter by value and by reference.

Answer:

Passing parameter by value, when a method is called a storage location is created for each
value parameter.

Passing parameter by reference is a reference to a memory location of a variable.


In passing parameter by value, the values of the actual parameters are copied into them.

In passing parameter by reference, when you pass parameter, a new storage location is
created for the parameter.

In passing parameter by value, the changes made to the parameter inside the method have
no effect on the argument.

In passing parameter by reference, the changes made to the parameter inside the method
have should effect on the argument.

In passing parameter by value, the reference parameters using Byval keyword.

In passing parameter by reference, the reference parameters using ByRef keyword.

5. IF ONE() ARRAY CONTAIN THREE VALUES ARE 1,2,4 AND TWO() ARRAY
HAVE THREE VALUES ARE 4,5,6. Using jagged array how to merge the one() and
two() arrays.

Answer :

Module Module1
Sub Main()
Dim one() As Integer = {1, 2, 3}
Dim two() As Integer = {3, 4, 5, 6, 7}
Dim jag()() As Integer = {one, two}
Dim i, j As Integer
For i = 0 To jag.Length - 1
For j = 0 To jag(i).Length - 1
Console.Write((jag(i)(j)))
Next
Console.WriteLine()
Next
Console.ReadLine()
End Sub
End Module

Result:

123
34567
SECTION-C

1. Give the procedure header for each of the following ?

a) Procedure hypendnce,when task 2 double pression floating point arguments side1.side2.and


returns a double permission floating point result

b) Procedure instruction which task three integer x,y,z retruns as integer

c) Procedure instruction which dose not task any argument and ose not return a value

ANSWER:

a) Function hypendence (by val side 1.as double side 2.as double)as double

b) Function smallest (by val x as integer ,y as integer z as integer )as integer

c) sub instruction ()

2. Find the value of X after each of the following statement is performed.

a)X=Math. Abs(7.5)

b) X=Math. Floor (7.5)

c) X=Math. Abs (0.0)

d) X=Math. Calling (6.0)

ANSWER:

a)x=8

b)x=7

c)x=0

d)x=6
3. Construct a program for sums for the values contained in 10 elements integer array.

ANSWER:

module mod summary

sub main()

dim array as integer ()= new integer (){1,2,3,4,5,6,7,8,9,10}

dim total as integer =0

I as integer =0

for i=0 to array 1.get upper bound (0)

total +=array(I)

msg box.show(total of array element & total)

end sub

end module

output

totl of aray element 55

4. Create a program for the following output using passing parameter by reference
ANSWER:

Private Function Addition(ByRef Value1 As Double, ByRef Value2 As Double)


Value1 = InputBox("Enter First Number: ")
Value2 = InputBox("Enter Second Number: ")

Addition = Value1 + Value2


End Function

Public Function Main() As Integer


Dim Result As String
Dim Number1, Number2 As Double

Result = Addition(Number1, Number2)


MsgBox(Number1 & " + " & Number2 & " = " & Result)
Return 0
End Function

End Module

6. Construct a program for the following output using passing parameter by value,

Before swap value of a = 100


Before swap value of a = 200
Before swap value of a = 200
Before swap value of a = 100
Answer :

Module param ByRef sub swap (Byval x as integer, byval y as integer)


Dim temp as integer
Temp = x
X=y
Y=temp
End sub
Sub main ()
Dim a as integer = 100
Dim b as integer = 200
Console.writeline (before swap value of a:, a)
Console.writeline (before swap value of a:, b)
Swap (a,b)
Console.writeline (After swap value of a:,a)
Console.writeline (after swap value of a:,b)
End sub
End module
UNIT III

SECTION-B

1. Construct the program display the color display box when a user clicks the command button as
the following constraints.

1. Declare common dialog.


2. Display the color dialog box.
3. Set the form background color.
ANSWER:

Private Sub Command1_Click ()


' Set Cancel to True.
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' Set the Flags property.
CommonDialog1.Flags = cdlCCRGBInit
' Display the Color dialog box.
CommonDialog1.ShowColor
' Set the form's background color to the selected
' color.
Form1.BackColor = CommonDialog1.Color
Exit Sub

2. Create a program using following parameters

a) Declare create graphics object


b) Use pen object for drawing lines.
c) Set the color for brush.
d) Give the value for X, Y, width &height.
ANSWER:

dim g as graphics:point event graphics

dim brush as solid brush=new solid brush (color,blue)

dim pen as pen:new pwn (color red)

g.fill rectangle (brush 90,30,150,90)

g.draw line (pen 30,110,40)


g.draw line(pen 240,30,110,40)

g.draw line(pen,240,30,260,120)

3. Develop a program using multimedia to display two images when you click the button
(command).

ANSWER:

private mimage as array list=new array list()

private m count as integer =1

dim I as integer

for i=0 to 1

m image.add(image form file(image logo &)

next

logo picture box.image(type (image(0)image)

private sub time-click()

mcount =(mcount + 1)mod

logo picture box.image+c type (image (m count),image)

4.Sketch out the font family methods with example.

1.getcell ascent

2. getcelldescent

3. getEmHeight

4.getlinespacing
Eg:

Dim graphicsobject as graphics = paintevent.graphics

Dim brush as solidbrush = new solidbrush (color.red)

Dim pen as pen = new pen (brush)

Dim arial as font = new font (Arial, 12)

Dim family as fontfamily =arial.fontfamily

Graphicsobject. Drawstring (ascent:&family.getcellascent (fontstyle.regular), arial, brush, 10,


30)

Graphicsobject. Drawstring (descent:&family.getcelldescent (fontstyle.regular), arial, brush,


10, 50)

Graphicsobject. Drawstring (ascent:& family.getemheight (fontstyle.regular), arial, brush, 10,


70)

Graphicsobject. Drawstring
(ascent:&family.getlinespacing(fontstyle.regular),arial,brush,10,90)

5. Create a simple program by using fillpie method.

Answer:

Dim graphicsobject as graphics = paintevent.graphics

Dim rectangle1 as rectangle = new rectangle (15, 35, 80, 80)

Dim brush1 as solidbrush = new solidbrush = new solidbrush (color.red)

Dim pen1 as pen = new pen (brush1, 1)

Dim brush2 as solidbrush = new solidbrush (color.blue)

Dim pen2 as pen = new pen (brush2, 1)

Rectangle1. Location = new point (185, 35)

Rectangle1.size = new size (80, 40)

Graphicsobject.drawrectangle (pen1, rectangle1)


Graphicsobject. Fillpie (brush2, rectangle1, 0,360)

SECTION C

1. Construct a program for the following output.

ANSWER:

dim g as graphics =paint event graphics

dim brush as solid brush :new solid brush (color,blue)

dim pen as pen=new pen (color,red)

g.rectangle(brush 90,30,150,120)

g.draw line(pen,120,30,140,40)

g.draw line (pen,100,25,40,180)

g.draw rectangle(pen 120,100,80,180) brush color= color green

dim brush as solid brush=new solid brush )color.green)

dim pen as pen=new pen (color.blue)

g.rectangle(brush 90,150,30,120)

g.draw line(pen,90,40,120,140)

g.draw line(pen 100,120,80,30)

g.draw rectangle(pen 110,180,125,90) brush=color=colr.green

dim as solid brush =new brush (color.pink)

dim pen as pen =new pen(color.yellow)


g.rectangle (brush,90,30,20,150)

g.draw l;ine(pen,120,150,30,80)

g.draw line(pen,150,40,20,125)

g.rectangle(pen,180,110,100,80)

g.draw line(pen,150,40,20,125)

g.rectangle(pen,180,11,100,80)(color)

2. Develop a program for the following output.

ANSWER:

graphics object.draw are(pen),rectangle

graphics object.draw are(pen,rectangle,0,100)

rectangle.location=new point(100,35)

graphics object.draw line rectangle(pen.rectangle)

graphics object.draw arc(pen1 rectangle,0,150)

rectangle.location=new point(180,165)

graphics object draw rectangle (pen rectangle)

graphics object.draw rectangle(pen,rectangle)

graphics object.draw arc(pen1,rectangle,0,180)

3. Create a program for set the following font properties in font dialog box.

a) Set the font name.


b) Set the font size.
c) Set the font style in bold.
d) Set the font style in italic.
e) Set the font style in underline.
ANSWER:

dim style as font style:font style.bold

dim arieal as font:new font (new font family(arieal 12.style)

style=font style-regular

dim times new roman as font style =font style italic

dim arieal as font=new font (new font family (arieal 12.style)

style=font style regular

dim times new roman as font =new font (times new roman)

dim style as font style =font style.under line

dim arieal as font =new font (new font family (arieal12.style)

style=font style.regular

dim times new roman as font =new font(tims new roman 12.style)
dim g as graphics:point event graphics

dim brush as solid brush=new solid brush (color,blue)

dim pen as pen:new pwn (color red)

g.fill rectangle (brush 90,30,150,90)

g.draw line (pen 30,110,40)

g.draw line(pen 240,30,110,40)

g.draw line(pen,240,30,260,120)

4. Construct a program for the following output using DrawLine method.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click

Dim myGraphics As Graphics = me.CreateGraphics

Dim myPen As Pen

myPen = New Pen(Brushes.DarkMagenta, 10)

myGraphics.DrawLine(myPen, 20, 20, 100, 20)

End Sub
5. create a program for the following output using draw polygon method,

Answer :

Private Sub BtnDraw_Click(sender As Object, e As EventArgs) Handles BtnDraw.Click

Dim myPen As Pen


Dim A As New Point(10, 10)
Dim B As New Point(100, 50)
Dim C As New Point(60, 150)
Dim myPoints As Point() = {A, B, C}
myPen = New Pen(Drawing.Color.Blue, 5)
Dim myGraphics As Graphics = Me.CreateGraphics
myGraphics.DrawPolygon(myPen, myPoints)

End Sub
UNIT IV

SECTION - B

1. Create a program using Files Stream Class for the following output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -1

ANSWER:

Module fileProg

SubMain()

Dim f1 AsFileStream=NewFileStream("test.dat", _

FileMode.OpenOrCreate,FileAccess.ReadWrite)

Dim i AsInteger

For i =0To20

f1.WriteByte(CByte(i))

Next i

f1.Position=0

For i =0To20

-Console.Write("{0} ", f1.ReadByte())

Next i

f1.Close()

Console.ReadKey()

EndSub

EndModule
2. Develop a vb.net program using create directory method.

ANSWER:

Imports System.IO
Module Module1
Sub Main()
Dim root As String = "C:\Temp"
Dim subdir As String = "C:\Temp\Mahesh"
'If directory does not exist, create it.
If Not Directory.Exists(root) Then
Directory.CreateDirectory(root)
End If
End Sub
End Module

3. Draw a diagram for data hierarchy.

DATABASE

FILE

RECORD

FIELD

BYTE

BIT

BIT:

Smallest unit of computer storage

BYTE:

Only possible two values (0 &1)


FIELD:

Collection of digits, Numbers and special symbols.

RECORD:

Collection of fields

FILE:

Collection of records

4. List out the properties of files and streams.

Answer:

1. Console. Out
2. Console. in
3. Console. Error
1.console .out:

Returns the standard output stream object,which enables a program to output data to the
screen.

2. console .in:

Returns the standard input stream object, which enables a program to input data from the
keyboard.

3.Console. Error:

Returns the standard error stream object , which enables a program to output error
message to the screen.

5. Create a program for the following constraints using directory methods,

a) Delete a directory b) get directories

a) Delete a directory
ANSWER:

Module Module1
Sub Main()
Dim root As String = "C:\Temp"
'If directory does not exist, don't even try
If Directory.Exists(root) Then
Directory.Delete(root)
End If
End Sub
End Module

b) get directories

ANSWER:

Module Module1
Sub Main()
Dim root As String = "C:\Temp"
Dim subdir As String = "C:\Temp\Mahesh"
'If directory does not exist, create it.
If Not Directory.Exists(root) Then
Directory.CreateDirectory(root)
End If
' Create sub directory
If Not Directory.Exists(subdir) Then
Directory.CreateDirectory(subdir)
End If
End Sub
End Module
Section C

1. Create a program for following constraints using file operations:

a. create a fie b. create a directory

c. get creation time of file d. get last access time of file

e. get last written time of file

ANSWER:

a. create a fie:
Dim filename as string
Filename = txtinput.text
If file.exits (filename) then
Textoutput.text=getinformation (filename).
b. Create a directory:
Imports System.IO
Module Module1
Sub Main()
Dim root As String = "C:\Temp"
Dim subdir As String = "C:\Temp\Mahesh"
'If directory does not exist, create it.
If Not Directory.Exists(root) Then
Directory.CreateDirectory(root)
End If
End Sub
End Module
c. get creation time of file:
Module Module1
Sub Main()
' Get and set file creation time
Dim fileName As String = "c:\Temp\Mahesh.txt"
File.SetCreationTime(fileName, DateTime.Now)
Dim dt As DateTime = File.GetCreationTime(fileName)
Console.WriteLine("File created time: {0}", dt.ToString())
Console.ReadLine()
End Sub
End Module
d. get last access time of file
Module Module1
Sub Main()
' Get and set file last access time
Dim fileName As String = "c:\temp\Mahesh.txt"
File.SetLastAccessTime(fileName, DateTime.Now)
Dim dt As DateTime = File.GetLastAccessTime(fileName)
Console.WriteLine("File last access time: {0}", dt.ToString())
Console.ReadLine()
End Sub
End Module
e. get last written time of file
Module Module1
Sub Main()
' Get and set file last access time
Dim fileName As String = "c:\temp\Mahesh.txt"
File.GetLastWriteTime(fileName, DateTime.Now)
Dim dt As DateTime = File. GetLastWriteTime(fileName)
Console.WriteLine("GetLastWriteTime: {0}", dt.ToString())
Console.ReadLine()
End Sub
End Module

2. Develop a program for following the output using reading data from a sequential access file.

ACCOUNT

FIRST NAME

LAST NAME
BALANCE

OPEN FILE

ANSWER:

Public class bank

Public withevents lblaccount as label

Public withevents lblfirstname as label

Public withevents lbllastname as label

Public withevents lblbalance as label

Public withevents txtaccount as textbox

Public withevents txtfirstname as textbox

Public withevents txtlastname as textbox

Public withevents txtbalance as textbox

Protected sub cmdopen_click()

Dim filechooser as openfiledialog = new openfiledialog()

Dim result as dialogresult = filechooser. Showdialog

Dim filename as string

Filename=filechooser.filename

Input=new filestream (filename, filemoded.open,fileaccess.read)


3. Build a program using Directory operations.

ANSWER:

a. Create a Directory

Imports System.IO
Module Module1
Sub Main()
Dim root As String = "C:\Temp"
Dim subdir As String = "C:\Temp\Mahesh"
'If directory does not exist, create it.
If Not Directory.Exists(root) Then
Directory.CreateDirectory(root)
End If
End Sub
End Module

b. Create Sub Directory

Imports System.IO
Module Module1
Sub Main()
Dim root As String = "C:\Temp"
Dim subdir As String = "C:\Temp\Mahesh"
'If directory does not exist, create it.
If Not Directory.Exists(root) Then
Directory.CreateDirectory(root)
End If
' Create sub directory
If Not Directory.Exists(subdir) Then
Directory.CreateDirectory(subdir)
End If
End Sub
End Module
c. Delete a directory

Imports System.IO
Module Module1
Sub Main()
Dim root As String = "C:\Temp"
'If directory does not exist, don't even try
If Directory.Exists(root) Then
Directory.Delete(root)
End If
End Sub
End Module

4. Sketch out the data hierarchy in detail with example.

Answer :

The smallest data item are called bits. Each data item or bit can assume either the value 0
or 1.
Decimal digits (0,1,2,3,4,5,6,7,8,9), letters (A to Z, a to z), special symbols (@,$,%,*,(,)).
Digits, letters and special symbols are referred to as character.
Composed of characters are fields.
A field is a group of characters that convey some meaning.
Composed of several fields are called record.
Group of relate records are called file.
Example:

File

Arun Bcomca
Kumar Bca

Record

Arun bcomca

Arun field

01001010 Byte
1 bit
5. Construct a program for how to access the random access file.

Dim UserToAdd As User

Dim UserFile As Integer

Dim RecordNumber As Long

'Read the data off the form and populate corresponding

'UserToAdd values

With UserToAdd

.UserID = Val(txt_UserID.Text)

.UserBarcode = txt_UserBarcode.Text

.Forename = txt_Forename.Text

.Surname = txt_Surname.Text

.AccessRights = cmb_AccessRights.Text

End With

'Find the next open space in the User File

UserFile = FreeFile()

'Now open the file used to store User records

FileOpen(UserFile, UserFileName, OpenMode.Random, OpenAccess.Write,


OpenShare.Shared, Len(UserToAdd))

RecordNumber = Len(UserFile) + 1

'Add the new user to the file

FilePut(UserFile, UserToAdd, RecordNumber)

FileClose(UserFile)
UNIT V

SECTION B

1. Create a program by using UPDATE query for the following conditions:


Firstname lastname
Harvey deitel
Paul deitel
Tem nieto
Sue smith
a) Change the last name of sue smith to johns using UPDATE query.
b) Change the first name for paul into david.
Answer :

a) Update authors
SET lastname = jones

Where lastname =smith and firstname =sue

b) Update authors
SET firstname = david

Where lastname =deitel and firstname =Paul

2. Develop a program for reading and writing xml files.


Imports System.Xml

Module Module1
Sub Main()
Using reader As XmlReader =XmlReader.Create("C:\perls.xml")
While reader.Read(
If reader.IsStartElement() Then

If reader.Name = "perls" Then


Console.WriteLine("Start <perls>element.")
ElseIf reader.Name = "article" Then
Console.WriteLine("Start <article> element.")
Dim attribute As String = reader("name")
If attribute IsNot Nothing Then
Console.WriteLine(" Has attribute name: {0}", attribute)
End If
If reader.Read() Then
Console.WriteLine(" Text node: {0}", reader.Value.Trim())
End If
End If

End If
End While
End Using
End Sub
End Module

Input text: perls.xml

<?xml version="1.0" encoding="utf-8" ?>


<perls>
<article name="backgroundworker">
Example text.
</article>
<article name="threadpool">
More text.
</article>
<article></article>
<article>Final text.</article>
</perls>
Write xml in vb.net:

Answer :

using System.Xml

public class Sample

public static void Main()

XmlTextWriter writer = new XmlTextWriter("titles.xml", null);

writer.WriteStartElement("items");

writer.WriteElementString("title", "Unreal Tournament 2003");

writer.WriteElementString("title", "C&C: Renegade");

writer.WriteElementString("title", "Dr. Seuss's ABC");

writer.WriteEndElement();

writer.Close();

}}

3. Build a program for using adrotator control in asp.net


<html>
<head>
<title> web form1</title>
<meta content=Microsoft name =generator>
<meta content = visual basic name = code language>
< meta content = java script name = script>
<meta name = target content = http://microsoft.com>
</head>
<body background=images/background.jpg>
<form id = form1 method = post runat = server>
<asp:label id=displaylabel style = index :101;left:36px;position:absolute;top:22px
Runat =server height = 28px width = 268px>Adrotator Example
</asp:label>
<asp:adrotator id=countryrotator style=index:102;left:36px;position:absolute runat
=server height = 72px advertisement file=adrotatorinformation.xml>
</asp:adrotator>
</form>
<body>
</html>
4. Construct the program using DELETE query.
Answer:

Sql> create a table class ( sno number(2), regno varchar2 ( 20), name varchar2 (10));
Sql> table created.
Sql> insert into class values (1,1u13ba001,ajith);
Sql> 1 row created.
Sql> insert into class values (2,1u13ba002,arun);
Sql> 1 row created.
Sql> insert into class values (3,1u13ba003,babu);
Sql> 1 row created.
Sql> select * from class;
Sql> sno regno name
1 1u13ba001 ajith
2 1u13ba001 arun
3 1u13ba001 babu
Sql> delete from class where name=arun;
5. Draw and explain about system architecture in asp.net.
Answer:

o Application layer is the form where we design using the controls like textbox,
labels, command buttons etc.

o Business layer is the class where we write the functions which get the data from
the application layer and passes through the data access layer.

o Data layer is also the class which gets the data from the business layer and
sends it to the database or gets the data from the database and sends it to the
business layer.
SECTION-C

1. Table Name: Employee


Employee_id First_name Last name Salary Joining date Department

1 John Abraham 1000000 01-JAN-13 12.00.00 AM Banking

2 Michael Clarke 800000 01-JAN-13 12.00.00 AM Insurance

3 Roy Thomas 700000 01-FEB-13 12.00.00 AM Banking

4 Tom Jose 600000 01-FEB-13 12.00.00 AM Insurance

5 Jerry Pinto 650000 01-FEB-13 12.00.00 AM Insurance

6 Philip Mathew 750000 01-JAN-13 12.00.00 AM Services

7 TestName1 123 650000 01-JAN-13 12.00.00 AM Services

8 TestName2 Lname% 600000 01-FEB-13 12.00.00 AM Insurance

QUERIES:

1. Get all employee details from the employee table


2. Get First_Name,Last_Name from employee table
3. Get all employee details from the employee table order by First_Name Ascending
4. Get all employee details from the employee table order by First_Name descending
5. Get employee details from employee table whose Salary greater than 600000
ANSWER:

1. SELECT * FROM EMPLOYEE;


2. SELECT First_name,Last_name from employee;
3. SELECT * FROM EMPLOYEE ORDERBY FIRST_NAME ASC;
4. SELECT * FROM EMPLOYEE ORDER BY FIRST_NAME DESC;
5. SELECT FIRST_NAME FROM EMPLOYEE WHERE SALARY>60000;

2. Create a program for using SELECT query.


ANSWER:

| ID | NAME | AGE | ADDRESS | SALARY |

|1|Ramesh|32|Ahmedabad|2000.00|

|2|Khilan|25|Delhi|1500.00|

|3| kaushik |23|Kota|2000.00|

|4|Chaitali|25|Mumbai|6500.00|

|5|Hardik|27|Bhopal|8500.00|

|6|Komal|22| MP |4500.00|

|7|Muffy|24|Indore|10000.0

SQL> SELECT ID, NAME, SALARY FROM CUSTOMERS;

| ID | NAME | SALARY |

1|Ramesh|2000.00|

|2|Khilan|1500.00|

|3| kaushik |2000.00|

|4|Chaitali|6500.00|

|5|Hardik|8500.00|

|6|Komal|4500.00|

|7|Muffy|10000.00|

+----+----------+----------+

If you want to fetch all the fields of CUSTOMERS table, then use the following query:

SQL> SELECT * FROM CUSTOMERS;


This would produce the following result:

+----+----------+-----+-----------+----------+

| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

|1|Ramesh|32|Ahmedabad|2000.00|

|2|Khilan|25|Delhi|1500.00|

|3| kaushik |23|Kota|2000.00|

|4|Chaitali|25|Mumbai|6500.00|

|5|Hardik|27|Bhopal|8500.00|

|6|Komal|22| MP |4500.00|

|7|Muffy|24|Indore|10000.00|

3. Build a program for using adrotator control in asp.net.


ANSWER:
<html>
<head>
<title> web form1</title>
<meta content=Microsoft name =generator>
<meta content = visual basic name = code language>
< meta content = java script name = script>
<meta name = target content = http://microsoft.com>
</head>
<body background=images/background.jpg>
<form id = form1 method = post runat = server>
<asp:label id=displaylabel style = index :101;left:36px;position:absolute;top:22px
Runat =server height = 28px width = 268px>Adrotator Example
</asp:label>
<asp:adrotator id=countryrotator style=index:102;left:36px;position:absolute runat
=server height = 72px advertisement file=adrotatorinformation.xml>
</asp:adrotator>
</form>
<body>
</html>

4.Draw and sketch out the ADO.NET object model.


Answer:

Data provider:

A data provider is used for connecting to a database , executing commands and retrieving data
and storing it in a dataset.

Connection:

Used to set up a connection wit ha data source

Command:
A command is a sql statement or a stored procedure.

Data reader:

Used to retrieve data from a data source in a read only mode.

Data adapter:

Retrieves data from a database

Data set:

Disconnected, cached set of records that are retrieve from a database.

5. Build a program for the following constraints using ADO.NET connectivity,


a. create a table (student) using SQL query.
b. insert the values for student name, class, marks, total.
c. connect the table (student) to vb.net program
d. display the result through SELECT query.
Answer:

SQL> CREATE TABLE STUDENT (SNAME VARCHAR2 (20), CLASS VARCHAR2 (10),
MARK NUMBER(3), TOTAL NUMBER(3));

SQL>TABLE CREATED.

SQL> INSERT INTO STUDENT VALUES (BABAU,BCOMCA,80,900);

SQL>1 ROW CREATED.

SQL>SELECT * FROM STUDENT;

OUTPUT:

SNAME CLASS MARK TOTAL

BABU BCOMCA 80 900

Vous aimerez peut-être aussi