Vous êtes sur la page 1sur 63

CONTENTS

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:

Enter the value for n: 5


01123

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.

Input form design:

3
Coding:
Public Class Form1
Dim curval, preval As Double
Dim operat As String
Dim result

Private Sub btnno1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnno1.Click
txtdispaly.Text = txtdispaly.Text & btnno1.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnno2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno2.Click
txtdispaly.Text = txtdispaly.Text & btnno2.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnno3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno3.Click
txtdispaly.Text = txtdispaly.Text & btnno3.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnno4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno4.Click
txtdispaly.Text = txtdispaly.Text & btnno4.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnno5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno5.Click
txtdispaly.Text = txtdispaly.Text & btnno5.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnno6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno6.Click
txtdispaly.Text = txtdispaly.Text & btnno6.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnno7_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno7.Click
txtdispaly.Text = txtdispaly.Text & btnno7.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnno8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno8.Click
txtdispaly.Text = txtdispaly.Text & btnno8.Text
curval = Val(txtdispaly.Text)
End Sub
Private Sub btnno9_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnno9.Click
txtdispaly.Text = txtdispaly.Text & btnno9.Text
curval = Val(txtdispaly.Text)

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

Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem6.Click
OpenFileDialog1.ShowDialog()
RichTextBox1.LoadFile(OpenFileDialog1.FileName,
RichTextBoxStreamType.PlainText)
End Sub

Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem7.Click
SaveFileDialog1.ShowDialog()
RichTextBox1.SaveFile(SaveFileDialog1.FileName,
RichTextBoxStreamType.PlainText)
End Sub

Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem8.Click
PrintDialog1.ShowDialog()
End Sub

Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem9.Click
End
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

Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem11.Click
SendKeys.Send("^y")
End Sub

Private Sub MenuItem12_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem12.Click
SendKeys.Send("^x")
End Sub

Private Sub MenuItem13_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem13.Click
SendKeys.Send("^c")
End Sub

Private Sub MenuItem14_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem14.Click
SendKeys.Send("^v")
End Sub

Private Sub MenuItem15_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem15.Click
SendKeys.Send("^a")
End Sub

Private Sub MenuItem16_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem16.Click
ColorDialog1.ShowDialog()
RichTextBox1.SelectionColor = ColorDialog1.Color

11
End Sub

Private Sub MenuItem17_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MenuItem17.Click
FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font
End Sub

Private Sub msword_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
RichTextBox1.clear
End Sub
End Class

Output:

Ex. No: 3 Developing a Timer Based Quiz using VB.NET.

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

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
If TextBox1.Text = "" Then
MsgBox("Enter Your Name", MsgBoxStyle.Critical)
Else
Panel4.Visible = True
lblTime.Text = 30
Timer1.Enabled = True
End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
If Val(lblTime.Text) = 0 Then
Timer1.Enabled = False
Else
lblTime.Text = Val(lblTime.Text) - 1
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Panel4.Visible = False
End Sub
End Class
Output Form:

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

Public Sub Main()


Try
Dim guest1 As Guest = New Guest("Ben", "Miller", 17)
Console.WriteLine(guest1.GuestInfo)
Catch outOfRange As ArgumentOutOfRangeException
Console.WriteLine("Error: {0}", outOfRange.Message)
End Try
End Sub

End Module

Class File:

Public Class guest


Private FirstName As String
Private LastName As String
Private Age As Integer

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

Public Function GuestInfo() As String


Dim gInfo As String = (FirstName + (" " _
+ (Me.LastName + (", " + Me.Age.ToString))))
Return gInfo
End Function
End Class

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:

The example displays the following output: 


Division of 3000 by zero.

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)

If (Counter Mod 3 = 0) Then


Numbers(NumbersCounter) = Counter
NumbersCounter = NumbersCounter + 1
Counter = Counter + 1

ElseIf (Counter Mod 5 = 0) Then


Numbers(NumbersCounter) = Counter
NumbersCounter = NumbersCounter + 1
Counter = Counter + 1
Else
Counter = Counter + 1
End If

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

Console.WriteLine(Total) 'Changed PrintLine which prints to a file to


Console.WriteLine which writes to the screen
Console.ReadLine 'Added a Console.ReadLine so the Window doesn't close
until you hit a key so you can see your answer

Output:

18
4:Try Catch Finally:
Module Module1

Sub Main()
Console.WriteLine("Zero")
Try
' Reached.
Console.WriteLine("One")

' An exception is thrown.


Dim s As String = Nothing
s = s.ToUpper()

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

Public Class Natural


Public Number As Integer
Public Sub New(ByVal N As Integer)
Number = N
End Sub
Public Shared Operator Not(ByVal Value As Natural) As Natural
Dim Nbr As Integer = Value.Number
Dim N As Integer = Not Nbr

Dim Nat As Natural = New Natural(N)

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

Dim Nat As Natural = New Natural(N)


Return Nat
End Operator

Public Overrides Function ToString() As String


Return Number.ToString()
End Function
End Class

Main Class

Public Function Main() As Integer


Dim Nbr As Natural

Nbr = New Natural(248)

MsgBox(Nbr.ToString() & " + 35 = " & (Nbr + 35).ToString())

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

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


<Advertisements>
<Ad>
<ImageUrl>innova.jpg</ImageUrl>
<NavigationUrl> </NavigationUrl>
<AlternateText>Innova</AlternateText>
<Impressions>7</Impressions>

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

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"


Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div> 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>
&nbsp;&nbsp;&nbsp;
<br />
&nbsp;<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>

24
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
OUTPUT:

Ex. No: 7 Program for implementing the different validations in ASP.NET

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" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="521px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label1" runat="server" Text="Registration Form"></asp:Label>
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label3" runat="server" Text="Age"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;
<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 &amp; Maximum 45"
MaximumValue="45"
MinimumValue="18"></asp:RangeValidator>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label4" runat="server" Text="Date of Birth"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label5" runat="server" Text="Mail Id"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label6" runat="server" Text="Password"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox5" runat="server"
TextMode="Password"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label7" runat="server" Text="Retype Password"></asp:Label>
&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox6" runat="server"
TextMode="Password"></asp:TextBox>
&nbsp;
<asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToCompare="TextBox5" ControlToValidate="TextBox6"

29
ErrorMessage="Password Missmatch"></asp:CompareValidator>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;
<asp:Label ID="Label8" runat="server" Text="Security Quet:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
Answer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="Submit" />
&nbsp;&nbsp;&nbsp;
</asp:Panel>
</div>
</form>
</body>
</html>

Registration.aspx coding

    Partial Class Default2

30
Inherits System.Web.UI.Page

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


Handles Button1.Click
Session("Name") = TextBox1.Text
Session("age") = TextBox2.Text
Session("Dob") = TextBox3.Text
Session("emailid") = TextBox4.Text
Session("SQuet") = DropDownList1.Text
Session("Answer") = TextBox7.Text
Response.Redirect("default.aspx")

End Sub

End Class    

Default.aspx

Partial Class _Default


Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Me.Load
Label1.Text = Session("Name")
Label2.Text = Session("age")
Label3.Text = Session("DOB")
Label4.Text = Session("Emailid")
Label5.Text = Session("Squest")
Label6.Text = Session("Answer")
End Sub
End Class

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" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="521px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label1" runat="server" Text="User Login"></asp:Label>
<br />
<br />
<br />

35
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label2" runat="server" Text="EmailID"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label3" runat="server" Text="Password"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server" EnableViewState="False"
TextMode="Password"></asp:TextBox>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Label ID="Label4" runat="server" Text="Date of Birth"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<br />

36
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="Submit" style="height: 26px" />
&nbsp;&nbsp;&nbsp;
</asp:Panel>
</div>
</form>
Default2.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 360px">

&nbsp;<br />
&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
&nbsp;
<br />
&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<br />
<br />
&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
<br />
<br />
&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
<br />

37
<br />
&nbsp;&nbsp;&nbsp;
<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

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


Handles Button1.Click
Session("EMail Id") = TextBox1.Text
Session("Dob") = TextBox3.Text
Response.Redirect("default.aspx")

End Sub

End Class
Default2.aspx
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Me.Load
Label1.Text = Session("EmailId")
Label3.Text = Session("DOB")

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 :

Public Class Form1


Structure student
Dim sno As Integer
Dim sname As String
Dim sage As Integer
End Structure
Dim i As Integer
Dim a() As student
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DataGridView1.Columns.Add("sno", "Student Number")
DataGridView1.Columns.Add("sname", "Student Name")
DataGridView1.Columns.Add("sage", "Student Age")

Dim i As Integer = 0
End Sub

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


System.EventArgs) Handles Button1.Click
ReDim Preserve a(i)
a(i).sno = Val(TextBox1.Text)
a(i).sname = TextBox2.Text
a(i).sage = Val(TextBox3.Text)
MsgBox("Information Updated", MsgBoxStyle.Information)
i=i+1
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
DataGridView1.Rows.Clear()
Dim sv As student
For Each sv In a
DataGridView1.Rows.Add(sv.sno, sv.sname, sv.sage)
Next
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

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"


Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button3" runat="server" Text="UPDATE" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button4" runat="server" Text="CALCULATE" />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;
Mark2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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bsp;&nbsp;
<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>
<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;
Average&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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

Dim con as sqlconnection = new sqlconnection(“Data Source=LENOVO-


1888CE70\SQLEXPRESS;Initial Catalog=astuddb;integrated Security=True”)
Dim cmd As SqlCommand
Dim s As String

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

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button3.Click

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

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button4.Click

Textbox1.text = ””
Textbox2.text = ””
Textbox3.text = ””
Textbox4.text = ””
Textbox5.text = ””
Textbox6.text = ””
Textbox7.text = ””
Textbox8.text = ””
Textbox9.text = ””
End Sub

Calculate

Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button5.Click

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

MDI Form (MDIParent1):

Withdrawal Form
(frmWithDraw):

New Account Form (frmCreateAcc): Balance Enquiry (frmBalance):

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

Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objcustdet, "bank").Position = 0
Me.objcustdet_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objcustdet, "bank").Position =
(Me.objcustdet.Tables("bank").Rows.Count - 1)
Me.objcustdet_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objcustdet, "bank").Position = (Me.BindingContext(objcustdet,
"bank").Position - 1)
Me.objcustdet_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objcustdet, "bank").Position = (Me.BindingContext(objcustdet,
"bank").Position + 1)
Me.objcustdet_PositionChanged()
End Sub
Private Sub objcustdet_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objcustdet, "bank").Position +
1).ToString + " of ") _
+ Me.BindingContext(objcustdet, "bank").Count.ToString)
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" >
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;<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

Vous aimerez peut-être aussi