Lab Manual
Lab Manual
PAGE
S.NO PROGRAM TITLE
NO
SAMPLE PROGRAMS 2
1 Designing a Simple Calculator using VB.NET. 3
2 Simulating a Text Editor using VB.NET. 9
3 Developing a Timer Based Quiz using VB.NET. 13
4 Writing a program for handling at least four exceptions using VB.NET. 16
5 Writing a program for implementing the overloading concept using 21
VB.NET.
6 Writing a program for loading different advertisements in a web page 23
using ADRotator in ASP.NET.
7 Performing the following validations in a Web Page using ASP. NET 26
a. Compare Validator
b. Custom Validator
c. Range Validator
8 Performing the following validations in a Web Page using ASP. NET 34
a. Regular Expression Validator
b. Required Field Validator
c. Validation summary
9 Writing a SQL query to fetch the data from two tables and display it in 41
the Data grid.
10 Establishing Database connection for binding Student Database through 44
Repeater control using ASP.NET.
11 Developing an Application for Banking using VB.NET. 52
12 Developing an Application for Online Shopping using ASP.NET. 61
1
SAMPLE PROGRAMS Fibonacci Series
Aim:
To write a program to Generate Fibonacci Series
Prerequisites:
To implement this program, the student should have knowledge on:
Arithmetic Operators
Variable Declaration
Loop Statements
Procedure:
Step 1: Start a process
Step 2: Get the n value from user
Step 3: Generate the Fibonacci series
Step 4: Stop the process
Coding:
Dim n, F1, F2, F3, i As Integer
F1 = -1
F2 = 1
Console.writeline(“Enter the value for n : ”);
N = val(Console.readline())
For i = 1 To n
F3 = F1 + F2
Console.write(“ ”,f3)
F1 = F2
F2 = F3
Next i
Output:
2
Ex. No: 1 Designing a Simple Calculator using VB.NET.
Aim:
To write a program to implement the simple calculator
Prerequisites:
To implement this program, the student should have knowledge on:
Arithmetic Operators
Variable Declaration
Placing Controls in Form
Writing appropriate code for events
Procedure:
Step 1: Start a process.
Step 2: Design a calculator using controls like buttons and textbox.
Step 3: The calculator includes the details about no’s from 0 to 9 and ‘.’ Button for
decimal ‘c’, Button for clear, operator buttons like “+,-,*, /, and =”.
Step 4: By using the equal button click we have to do any operations in the calculator.
Step 5: Stop the process.
3
Coding:
Public Class Form1
Dim curval, preval As Double
Dim operat As String
Dim result
4
End Sub
Private Sub btnno0_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno0.Click
txtdispaly.Text = txtdispaly.Text & btnno0.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btndot_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btndot.Click
txtdispaly.Text = txtdispaly.Text & btndot.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnadd.Click
txtdispaly.Text = ""
preval = curval
curval = 0
operat = "+"
End Sub
Private Sub btnsub_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnsub.Click
txtdispaly.Text = ""
preval = curval
curval = 0
operat = "-"
End Sub
Private Sub btnmul_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnmul.Click
txtdispaly.Text = ""
preval = curval
curval = 0
operat = "*"
End Sub
Private Sub btndiv_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btndiv.Click
txtdispaly.Text = ""
preval = curval
curval = 0
operat = "/"
End Sub
Private Sub btnaddsub_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnaddsub.Click
txtdispaly.Text = ""
curval = -curval
txtdispaly.Text = curval
End Sub
Private Sub btnmod_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnmod.Click
txtdispaly.Text = ""
preval = curval
curval = 0
5
operat = "mod"
End Sub
Private Sub btntan_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntan.Click
txtdispaly.Text = ""
preval = curval
curval = 0
operat = "tan"
End Sub
Private Sub btnsin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnsin.Click
txtdispaly.Text = ""
preval = curval
curval = 0
operat = "sin"
End Sub
Private Sub btncos_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btncos.Click
txtdispaly.Text = ""
preval = curval
curval = 0
operat = "cos"
End Sub
Private Sub btnsqr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnsqr.Click
txtdispaly.Text = ""
preval = curval
curval = 0
operat = "^"
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnclear.Click
curval = preval = 0
txtdispaly.Text = ""
End Sub
Private Sub btnequal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnequal.Click
If operat = "+" Then
result = preval + curval
txtdispaly.Text = Val(result)
curval = result
End If
If operat = "-" Then
result = preval - curval
txtdispaly.Text = Val(result)
curval = result
End If
If operat = "*" Then
result = preval * curval
txtdispaly.Text = Val(result)
6
curval = result
End If
If operat = "/" Then
result = preval / curval
txtdispaly.Text = Val(result)
curval = result End If
If operat = "^" Then
result = preval ^ 2
txtdispaly.Text = Val(result)
curval = result
End If
If operat = "sin" Then
result = Math.Sin(preval)
txtdispaly.Text = Val(result)
curval = result
End If
If operat = "cos" Then
result = Math.Cos(preval)
txtdispaly.Text = Val(result)
curval = result
End If
If operat = "tan" Then
result = Math.Tan(preval)
txtdispaly.Text = Val(result)
curval = result
End If
If operat = "mod" Then
result = preval Mod curval
txtdispaly.Text = Val(result)
curval = result
End If
End Sub
End Class
Output:
7
8
Ex. No: 2 Simulating a Text Editor using VB.NET
Aim:
To design a text editor with edit options
Prerequisites:
To implement this program, the student should have knowledge on:
Placing Controls in Form
Dialog Boxes
Writing appropriate code for events
Creating Menu Bar
Procedure:
Step 1: Start the process
Step 2: Design form with Menu, Rich Edit Text box and Windows Common dialogs
Step 3: In the menu, create options for file new, open, save, print, close, change font,
change color, cut, copy, paste like choices.
Step 4: Write the code for the above operations in the click event of the menu items
Stop 5: Stop the process
Input Form:
9
Coding:
Public Class msword
Inherits System.Windows.Forms.Form
Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem5.Click
RichTextBox1.Clear()
RichTextBox1.Focus()
End Sub
10
Private Sub MenuItem10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem10.Click
SendKeys.Send("^z")
End Sub
11
End Sub
Output:
Aim:
To develop an application for Quiz using VB .NET
12
Prerequisites:
To implement this program, the student should have knowledge on:
Placing Controls in Form
Timer Control
Grouping Controls in Panels
Procedure:
Step1: Start the process
Step2: Design a form with labels, radio buttons, textbox, and buttons.
Step3: Validate the answers and display the total number of correct answers.
Step4: Stop the process.
Input form:
Coding:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Timer1.Enabled = False
13
Calculate()
End Sub
Sub Calculate()
Dim score As Integer = 0
If RadioButton3.Checked = True Then
score = score + 1
End If
If RadioButton6.Checked = True Then
score = score + 1
End If
If RadioButton11.Checked = True Then
score = score + 1
End If
Panel4.Visible = False
MsgBox(TextBox1.Text & ", Your Score is " & score, MsgBoxStyle.Information,
"Your Result")
End Sub
14
Ex. No: 4 Program for handling at least four exceptions using VB.NET.
Aim:
To write a VB .NET program for exception handling
Prerequisites:
To implement this program, the student should have knowledge on:
Placing Controls in Form
Detecting the exceptions
Throwing exception
Procedure:
Step1: Start the process
Step2: Design a form with labels, radio buttons, textbox, and buttons.
Step3: Validate the answers and display the total number of correct answers.
Step4: Stop the process.
15
1. Argument out of Range Exception
Main Module:
Module Module1
End Module
Class File:
Public Sub New(ByVal fName As String, ByVal lName As String, ByVal age As
Integer)
MyBase.New()
FirstName = fName
LastName = lName
If (age < 21) Then
Throw New ArgumentOutOfRangeException("age", "All guests must be 21-years-
old or older.")
Else
age = age
End If
End Sub
Output:
16
2.Divide by Zero Exception:
Module exceptionProg
Sub division(ByVal num1 As Integer, ByVal num2 As Integer)
Dim result As Integer
Try
result = num1 \ num2
Catch e As DivideByZeroException
Console.WriteLine("Exception caught: {0}", e)
Finally
Console.WriteLine("Result: {0}", result)
End Try
End Sub
Sub Main()
division(25, 0)
Console.ReadKey()
End Sub
End Module
Output:
3.System.IndexoutofRange Exception:
Sub Main()
Dim Counter As Integer = 1
Dim Numbers(1000) As Integer 'Initialized the Array so it will be usable.
Dim NumbersCounter As Integer = 0
17
Dim Total As Integer = 0
While (Counter <= 1000)
End While
Counter = 0
While (Counter <= Numbers.Length - 1) ' Arrays are zero based so you need to
subtract 1 from the length or else you will overflow the bounds
If (Counter = 0) Then
Total = Numbers(Counter)
Counter = Counter + 1
Else
Total = Total + Numbers(Counter) 'You were multiplying here not adding
creating a HUGE number
Counter = Counter + 1
End If
End While
Output:
18
4:Try Catch Finally:
Module Module1
Sub Main()
Console.WriteLine("Zero")
Try
' Reached.
Console.WriteLine("One")
Catch ex As Exception
' Reached.
Console.WriteLine("Two")
Finally
' Reached.
Console.WriteLine("Three")
End Try
Console.WriteLine("Four")
End Sub
End Module
Output:
19
Zero
One
Two
Three
Four
Ex. No: 5 Program for implementing the overloading concept using VB.NET.
Aim:
To write a program to implement the overloading concepts
Procedure:
Step 1: Start a process.
Step 2: Open a Console Application
Step 3: Create a main class and declare the necessary variables.
Step 4: Implement overloading concept in class file.
Step 5: Stop the process.
20
Coding:
Class file
Return Nat
End Operator
Public Shared Operator +(ByVal Value As Natural, ByVal Add As Integer) As Natural
Dim Nbr As Integer = Value.Number
Dim N As Integer = Nbr + Add
Main Class
Return 0
End Function
Output:
21
Ex. No: 6 Program for loading different advertisements in a web page using AD
Rotator in ASP.NET.
Aim:
To write a program to implement the AD Rotator in ASP.NET
Prerequisites:
To implement this program, the student should have knowledge on:
Creation of xml file
Placing AD Rotator in form
Writing appropriate code for events
22
Procedure:
Step 1: Start the program
Step 2: In Website application, select the AD Rotator from tool box.
Step 3: Add an xml file into the solution explorer and add image
Step 4: Add AD Rotator control into the form in that properties advertisement.
Step 5: Stop the process.
XML File
</Ad>
<Ad>
<ImageUrl>Benz.jpg</ImageUrl>
<NavigationUrl> </NavigationUrl>
<AlternateText>Benz</AlternateText>
<Impressions>12</Impressions>
23
</Ad>
<Ad>
<ImageUrl>maruti zen.jpg</ImageUrl>
<NavigationUrl> </NavigationUrl>
<AlternateText>maurti zen</AlternateText>
<Impressions>14</Impressions>
</Ad>
<Ad>
<ImageUrl>bmw.jpg</ImageUrl>
<NavigationUrl> </NavigationUrl>
<AlternateText>bmw</AlternateText>
<Impressions>12</Impressions>
</Ad>
</Advertisements>
ASP Coding :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div> ONLINE AUTOMOBILE SHOW ROOM
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<br />
<br />
<asp:ScriptManager ID="ScriptManager1"
runat="server"></asp:ScriptManager>
<asp:AdRotator ID="AdRotator2" runat="server"
DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/XMLFile.xml">
</asp:XmlDataSource>
<br />
<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>
24
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
OUTPUT:
Aim:
To implement the compare, custom and range validations in a registration form
Prerequisites:
To implement this program, the student should have knowledge on:
Place Compare Validator in form
Place Custom Validator in form
Place Range Validator in form
Procedure:
Step 1: Start the program
Step 2: In registration form, place compare, custom and range validator
25
Step 3: Write the appropriate error message for validator
Step 4: Stop the process
INPUT DESIGN
26
CODING:
27
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="521px">
&
nbsp; &n
bsp; &nbs
p;
&
nbsp; &n
bsp;
<asp:Label ID="Label1" runat="server" Text="Registration Form"></asp:Label>
<br />
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>
&
nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator2" runat="server"
ControlToValidate="TextBox1" Display="Dynamic"
ErrorMessage="A name should be minimum 5 and maximum 12"
SetFocusOnError="True"
ValidateEmptyText="True"></asp:CustomValidator>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label3" runat="server" Text="Age"></asp:Label>
&
nbsp; &n
bsp;
<asp:TextBox ID="TextBox2" runat="server"
EnableViewState="False"></asp:TextBox>
28
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox2"
ErrorMessage="The Minimum age should be 18 & Maximum 45"
MaximumValue="45"
MinimumValue="18"></asp:RangeValidator>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label4" runat="server" Text="Date of Birth"></asp:Label>
&
nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label5" runat="server" Text="Mail Id"></asp:Label>
&
nbsp;
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label6" runat="server" Text="Password"></asp:Label>
&
nbsp;
<asp:TextBox ID="TextBox5" runat="server"
TextMode="Password"></asp:TextBox>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label7" runat="server" Text="Retype Password"></asp:Label>
<asp:TextBox ID="TextBox6" runat="server"
TextMode="Password"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToCompare="TextBox5" ControlToValidate="TextBox6"
29
ErrorMessage="Password Missmatch"></asp:CompareValidator>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label8" runat="server" Text="Security Quet:"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" Height="24px"
Width="238px">
<asp:ListItem>1.What is your Favt Color</asp:ListItem>
<asp:ListItem>2.Who is your Favt Sports person?</asp:ListItem>
</asp:DropDownList>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Answer
<asp:TextBox ID="TextBox7" runat="server" Width="196px"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator3" runat="server"
ControlToValidate="TextBox7" Display="Dynamic" ErrorMessage="Enter your
answer"
SetFocusOnError="True"
ValidateEmptyText="True"></asp:CustomValidator>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
&
nbsp;
<asp:Button ID="Button1" runat="server" Text="Submit" />
</asp:Panel>
</div>
</form>
</body>
</html>
Registration.aspx coding
30
Inherits System.Web.UI.Page
End Sub
End Class
Default.aspx
OUTPUT DESIGN
31
32
Ex. No: 8 Program for implementing the different validations in ASP.NET
Aim:
To implement the required field, regular expression and validation summary in a
login form
Prerequisites:
To implement this program, the student should have knowledge on:
Place Required field Validator in form
Place Regular expression Validator in form
Place Validation summary in form
Procedure:
Step 1: Start the program
Step 2: In login form, place required field, regular expression and validation summary
Step 3: Write the appropriate error message for validator
Step 4: Stop the process
33
INPUT DESIGN:
34
CODING:
ASP Code(Default.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="521px">
&
nbsp; &n
bsp; &nbs
p;
&
nbsp; &n
bsp;
<asp:Label ID="Label1" runat="server" Text="User Login"></asp:Label>
<br />
<br />
<br />
35
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label2" runat="server" Text="EmailID"></asp:Label>
&
nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="Enter Correct Mail ID"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+
([-.]\w+)*"></asp:RegularExpressionValidator>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label3" runat="server" Text="Password"></asp:Label>
&
nbsp;
<asp:TextBox ID="TextBox2" runat="server" EnableViewState="False"
TextMode="Password"></asp:TextBox>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
<asp:Label ID="Label4" runat="server" Text="Date of Birth"></asp:Label>
&
nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox3" ErrorMessage="Enter Your Date Of
Birth"></asp:RequiredFieldValidator>
<br />
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
&
nbsp; &n
bsp; &nbs
p;
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<br />
36
&
nbsp; &n
bsp; <br />
&
nbsp; &n
bsp; &nbs
p;
&
nbsp;
<asp:Button ID="Button1" runat="server" Text="Submit" style="height: 26px" />
</asp:Panel>
</div>
</form>
Default2.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 360px">
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
<br />
37
<br />
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
Coding
Defaulf.aspx
Partial Class Default2
Inherits System.Web.UI.Page
End Sub
End Class
Default2.aspx
Partial Class _Default
Inherits System.Web.UI.Page
End Sub
End Class
38
OUTPUT FORM:
39
EX.NO:9 Program for implementing the DATA GRID
Aim:
To write a program to fetch the data from two tables and display it in the Data
grid.
Prerequisites:
To implement this program, the student should have knowledge on:
Data Grid
ADO .NET connectivity
Procedure:
Step 1: Start the process.
Step 2: To write a query for SQL SERVER Database.
Step 3: To connection is established the ADO.NET.
Step 4: Select the field on the table to display a grid view control.
Step 5: Stop the process
40
CODING :
Dim i As Integer = 0
End Sub
End Class
41
Output:
42
EX.NO:9 Program for implementing the Repeater control using ASP.NET.
Aim:
To write a program to Establishing Database connection for binding Student
Database through Repeater control using ASP.NET.
.
Prerequisites:
To implement this program, the student should have knowledge on:
Data binding
Data Repeater
Procedure:
Step 1: Start the process.
Step 2: Select the field on the table and manage the data
Step 3: To connection is established the ADO.NET
Step 4: Through repeater fetch the data from the database
Step 5: Stop the process
43
INPUT DESIGN
44
Coding
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
&
nbsp;
<br />
&
nbsp; &n
bsp; &nbs
p;
&
nbsp; &n
bsp;
<asp:Label ID="Label1" runat="server" Text="Student Information
System"></asp:Label>
<br />
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Student Roll
No &nbs
p;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Student
Name &n
45
bsp; &nbs
p;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
&
nbsp;
<asp:Button ID="Button1" runat="server" Text="INSERT" />
<asp:Button ID="Button2" runat="server" Text="DELETE" />
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Mark1 &nbs
p;
&
nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
&
nbsp;
<asp:Button ID="Button3" runat="server" Text="UPDATE" />
<asp:Button ID="Button4" runat="server" Text="CALCULATE" />
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Mark2 &nbs
p;
&
nbsp;
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
&
nbsp;
<asp:Button ID="Button5" runat="server" Text="CLEAR" />
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Mark3 &nbs
p;
&
nbsp;
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<br />
46
<br />
&
nbsp; &n
bsp; &nbs
p;
Mark4 &nbs
p;
&
nbsp;
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Mark5 &nbs
p;
&
nbsp;
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Total  
;
&
nbsp;
<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>
<br />
<br />
&
nbsp; &n
bsp; &nbs
p;
Average &n
bsp; &nbs
p;
<asp:TextBox ID="TextBox9" runat="server"></asp:TextBox>
<br />
<br />
<br />
<br />
<asp:Repeater ID="Repeater1" runat="server">
</asp:Repeater>
<br />
<br />
47
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Coding
Connection string
Imports system.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Insert
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button1.Click
Con.Open()
s = “insert into astudtable values(‘“ + textbox1.text + ‘”,’” + textbox2.text + ‘”,’” +
textbox3.text + ‘”,’” + textbox4.text + ‘”,’” + textbox5.text + ‘”,’” + textbox6.text + ‘”,’” +
textbox7.text + ‘”,’” + textbox8.text + ‘”,’” + textbox9.text + ‘”)”
cmd=newsqlcommand(s,con)
cmd.ExecuteNonQuery()
MsgBox(“Record added”)
Con.Close()
End Sub
Delete
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button2.Click
48
Con.Open()
S=”delete astudtable where sid=’” + textbox1.text + ‘”
Cmd=new Sqlcommand(s,con)
cmd.ExecuteNonQuery()
MsgBox(“Record deleted”)
Con.Close()
End Sub
Update
Con.Open()
s = “update astudtable set sid=‘“ + textbox1.text + ‘”,sname=’” + textbox2.text +
‘”,mark1=’” + textbox3.text + ‘”,mark2=’” + textbox4.text + ‘”,mark3=’” + textbox5.text +
‘”,mark4=’” + textbox6.text + ‘”,mark5=’” + textbox7.text + ‘”,total=’” + textbox8.text +
‘”,avg=’” + textbox9.text + ‘”where sid=’” + textbox1.text + ‘””
cmd.new sqlcommand(s,con)
cmd.ExecuteNonQuery()
MsgBox(“record updated”)
Con.close()
End Sub
Clear
Textbox1.text = ””
Textbox2.text = ””
Textbox3.text = ””
Textbox4.text = ””
Textbox5.text = ””
Textbox6.text = ””
Textbox7.text = ””
Textbox8.text = ””
Textbox9.text = ””
End Sub
Calculate
49
Textbox8.text = val(textbox3.text) + val(textbox4.text) + val(textbox5.text) +
val(textbox6.text) + val(textbox7.text)
Textbox9.text = val(textbox8.text) / 5
End sub
End class
OUTPUT DESIGN
50
EX.NO:11 Program for Online Banking Systems
Aim:
To develop an application for Online Banking System.
Prerequisites:
To implement this program, the student should have knowledge on:
Database and Table creation using MS Access
ADO.NET connectivity
Accessing Table data through coding
Procedure:
Step1: Start the process.
Step2: Design forms for customer account details, login, withdraw, deposit, balance
inquiry using windows components.
Step3: In the main form it have two buttons customer account details and login.
Step4: Customer register button is click to link the customer register form. Login
button is click to link the login form window.
Step5: In the login form have three buttons withdraw, deposit and balance inquiry.
Step6: Click the button to link the form window.
Step7: Create three objects connection, data adapter and dataset.
Step8: Using fill method to copy the data from database to datagrid.
Step9: Using databindings to add the text from table to textbox.
Step10: In customer account details to create an new account using addnew and
endcurrentedit fuctions.
Step10: In withdraw form find the current balance
Current balance=current balance - withdraw amount.
Step11: In deposit form to find
Current balance=current balance + deposit amount.
Step12: Stop the process
51
Input Forms:
Login Form(frmLogin): Deposit Form (frmDeposit):
Withdrawal Form
(frmWithDraw):
Coding:
Public Class banking
Inherits System.Windows.Forms.Form
52
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objcustdet, "bank").CancelCurrentEdit()
Me.objcustdet_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objcustdet, "bank").Count > 0) Then
Me.BindingContext(objcustdet,
"bank").RemoveAt(Me.BindingContext(objcustdet, "bank").Position)
Me.objcustdet_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objcustdet, "bank").EndCurrentEdit()
Me.BindingContext(objcustdet, "bank").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objcustdet_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception
'Add your error handling code here.
'Display error message, if any.
53
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objcustdet_PositionChanged()
End Sub
54
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As bankingdet.custdet = New bankingdet.custdet
'Stop any current edits.
Me.BindingContext(objcustdet, "bank").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objcustdet.GetChanges, bankingdet.custdet)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource
by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)
objcustdet.Merge(objDataSetChanges)
objcustdet.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try
'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As bankingdet.custdet
objDataSetTemp = New bankingdet.custdet
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
55
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objcustdet.Clear()
'Merge the records into the main dataset.
objcustdet.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try
End Sub
Public Sub UpdateDataSource(ByVal ChangedRows As bankingdet.custdet)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As bankingdet.custdet)
'Turn off constraint checking before the dataset is filled.
56
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.
dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub banking_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objcustdet_PositionChanged()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.Close()
57
End Sub
Private Sub editcredit_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles editcredit.TextChanged
Dim curbal As Decimal
curbal = Val(editaccbalance.Text) + Val(editcredit.Text)
editaccbalance.Text = curbal.ToString()
End Sub
Private Sub editdebit_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles editdebit.TextChanged
Dim curbal As Decimal
curbal = Val(editaccbalance.Text) - Val(editdebit.Text)
editaccbalance.Text = curbal.ToString()
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click
End Sub
End Class
Output Form:
58
EX.NO:12 Program for Online Shopping System
59
Aim:
To create an online shopping system using ADO.Net
Prerequisites:
To implement this program, the student should have knowledge on:
Database and Table creation using MS Access
ADO.NET connectivity
Accessing Table data through coding
Procedure:
Step 1: Start the progrm.
Step 2:Create required html pages and webpage.
Step 3: Connection those page.
Step 4 : Run the website using internet explorer.
Step 5 : Stop the process.
Input Form:
Coding:
Home.html
60
<html> <frameset rows="15%,75%">
<frame src="name.html"></frame>
<frame src="product.html"></frame>
</frameset frameset>
</html>
Name.html
<html >
<body>
<marquee behavior=> <h1> Online Shopping System</h1> </marquee>
</body>
</html>
Product.html
<html>
<head>
<frameset cols="25%,75%">
<frame src="menu.html" name="x"></frame>
<frame src="mobile.html" name="y"></frame>
</frameset>
</head>
</html>
Menu.html
<html>
<body>
<ol >
<li >
<a href ="mobile.html" target="y">Mobile</a>
</li><li ><a href ="watch.html" target="y">Watch</a></li>
</ol>
</body>
</html>
Mobile.html
<html >
<body>
<img src="E:\arun\net\mobile.jpg" />
<a href ="Default.aspx" >Buy it Now</a>
</body>
</html>
Watch.html
<html>
<body>
<img src="E:\arun\net\watch.jpg" />
<a href ="Default.aspx" >Buy It Now</a>
</body>
</html>
Default.aspx
<%@ Import Namespace ="System.data" %>
<%@ Import Namespace ="System.Data.oleDb" %>
<script runat ="server">
Sub submit(ByVal source As Object, ByVal e As EventArgs)
Dim Name, Address, Creditcardno
61
Name = Request.Form("Name")
Address = Request.Form("Address")
Creditcardno = Request.Form("Creditcardno")
Dim StrCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\employee.mdb;Persist Security Info=False"
Dim mysql As String = "INSERT INTO emp (Name,Address,Creditcardno) values
('" & Name & "','" & Address & "'," & Creditcardno & ")"
Dim con As New OleDbConnection(StrCon)
Dim cmd As New OleDbCommand(mysql, con)
con.Open()
cmd.ExecuteNonQuery()
'Response.Write()
MsgBox("One Record Inserted")
con.Close()
End Sub
</script>
<html >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<center><h1 > ONLINE SHOPPING SYSTEM</h1></center>
<center >
<form id="form1" runat="server">
<asp:Table ID="Table1" runat="server" >
<asp:TableRow ID="TableRow1" runat ="server" >
<asp:TableCell ID ="TableCell1" runat ="server" >Name:</asp:TableCell>
<asp:TableCell ID="TableCell2" runat ="server" ><asp:TextBox ID ="Name"
runat="server" ></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TableRow2" runat="server" >
<asp:TableCell ID="TableCell3" runat ="server" >Address</asp:TableCell>
<asp:TableCell ID="TableCell4" runat ="server" ><asp:TextBox ID ="Address"
runat="server" ></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID ="TableRow3" runat="server" >
<asp:TableCell ID="TableCell5" runat ="server" >CreditcardNo</asp:TableCell>
<asp:TableCell ID="TableCell6" runat ="server" ><asp:TextBox ID="Creditcardno"
runat="server" ></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TableRow4" runat="server" >
<asp:TableCell ID ="TableCell7" runat ="server" >
<asp:Button ID="Button1" Text="Click Me" runat="server"
OnClick ="submit" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
62
</center>
</body>
</html>
Output form:
63