Sei sulla pagina 1di 56

LAKSHMI AMMAL POLYTECHNIC COLLEGE

K.R.NAGAR, KOVILPATTI- 628 503.

DIPLOMA IN COMPUTER ENGINEERING


PRACTICAL WORK BOOK
(L-SCHEME)

25257- .NET PROGRAMMING PRACTICAL

NAME

REGISTER NO.

ROLL NO.

YEAR

SEMESTER

25257 - .NET PROGRAMMING PRACTICAL

25257 - .NET PROGRAMMING PRACTICAL

LAB EXERCISES
PART A
VB.NET PROGRAMMING
1. Accept a character from console and check the case of the character.
2. Write a program to accept any character from keyboard and display whether it is
vowel or not.
3. Write a VB.Net program to accept a string and convert the case of the characters.
4. Develop a menu based VB.Net application to implement a text editor with cut, copy,
paste, save and close operations.
5. Write a program to implement a calculator with memory and recall operations.
6. Develop a form in VB.NET to pick a date from Calendar control and display the day,
month, and year details in separate text boxes.
7. Develop a VB.Net application to perform timer based quiz of 10 questions.
8. Develop a VB.Net application using the File and Directory controls to implement a
common dialog box.
9. Develop a database application to store the details of students using ADO.NET
10. Develop a database application using ADO.NET to insert, modify, update and delete
operations.
11. Develop a VB.Net application using Datagrid to display records.
12. Develop a VB.Net application using Datagrid to add, edit and modify records.
PART B
ASP.NET and XML PROGRAMMING
1. Create a simple ASP.NET page to Output Text with a form, two HTML text boxes,
an HTML button, and an HTML <span> element. Create an event procedure for the
button.
2. Create a web application in ASP.NET using three different controls to the ASP.NET
page for reserving rooms in hotel. The three controls are a button control, a label
control, and a drop-down list control.
3. Create a application for Accessing a SQL Database by Using ADO.NET by
connecting to the SQL Server database and call a stored procedure. You then display
the data in a Repeater control.
4. Develop a web application to read the details of the selected country stored in XML
database and display back to the user using Web controls
5. Develop a web application to read an XML document containing subject, mark
scored, year of passing into a Dataset
LAPC

Page 1

25257 - .NET PROGRAMMING PRACTICAL

INDEX
Expt
No.

Date

Name of the Experiment

Page Marks
Staff
No.
Signature

PART A
1

Check the case of the Character

Vowel Checking

Case Conversion

Text Editor Creation

10

Calculator

12

Calendar Application

15

Quiz Creation

17

File and Folder Control

21

Database Creation using ADO.NET

23

10

Database Updation using ADO.NET

26

11

Table View using Datagrid

30

12

Database Creation using ADO.NET

32

PART B
1

Simple Web creation using ASP.NET

36

Hotel Reservation Using ASP.NET

39

Database Access Using Stored Procedure

42

XML with ASP.NET

45

XML with Dataset

47

Beyond Syllabus
1
2

LAPC

Page 2

25257 - .NET PROGRAMMING PRACTICAL

Part-A
VB.Net Programming

LAPC

Page 3

25257 - .NET PROGRAMMING PRACTICAL

CHECK THE CASE OF THE CHARACTER

Ex.No. : 1

AIM:
Create an application to accept a character from console and check the case of the character.
PROCEDURE:
1.
2.
3.
4.
5.
6.

Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005


Select File New Project Windows Application.
View the solution explorer, right click on the project name and select properties.
Set the application type as console application.
Edit the following code in the load event.
Run the application by pressing F5 key or by clicking debug button.

PROGRAM:
Form_Load
Dim c As Char
Console.WriteLine("Enter the character")
c = Console.ReadLine
If Asc(c) > 64 And Asc(c) < 91 Then
Console.WriteLine("Upper case")
ElseIf Asc(c) > 96 And Asc(c) < 122 Then
Console.WriteLine("Lower case")
Else
Console.WriteLine("Other Character")
End If
SAMPLE OUTPUT:

LAPC

Page 4

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the program for check the case of the character was executed and the output was
verified.
LAPC

Page 5

25257 - .NET PROGRAMMING PRACTICAL

VOWEL CHECKING

Ex.No. : 2

AIM:
Write a VB.Net program to accept any character from keyboard and display whether it is
vowel or not.
PROCEDURE:
1.
2.
3.
4.
5.

Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005


Select File New Project Windows Application.
Place the label, textbox and button in the window.
Write the code in click event of btnresult.
Run the application by pressing F5 key or by clicking debug button.

PROGRAM:
btnresult_Click
Dim c As Char
c = UCase(txtinput.Text)
If c = "A" Or c = "E" Or c = "I" Or c = "O" Or c = "U" Then
txtoutput.Text = "VOWEL"
Else
txtoutput.Text = "NOT VOWEL"
End If
btnclear_Click
txtinput.clear()
txtoutput.clear()
SAMPLE OUTPUT:

LAPC

Page 6

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the program for vowel checking was executed and the output was verified.

LAPC

Page 7

25257 - .NET PROGRAMMING PRACTICAL

CASE CONVERSION

Ex.No. : 3

AIM:
Write a VB .NET program to accept a string and convert the case of the characters.
PROCEDURE:
Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005
Select File New Project Windows application.
Open the Windows application.
Place a label and text as enter the string.
Place two textboxes one is used to enter the string, other used to display the result.
Then place two buttons, one is used to display result and other used to clear the
textboxes.
7. Then write the code in click event of button1 and button2.
8. Run the application by F5 key or pressing debug button.
1.
2.
3.
4.
5.
6.

PROGRAM:
Button1_Click
Dim len, i As Integer
Dim s, c As String
s = txtinput.Text
len = s.Length
For i = 1 To len
c = Mid(s, i, 1)
If Asc(c) > 96 And Asc(c) < 123 Then
txtoutput.AppendText(UCase(c))
Else
txtoutput.AppendText(LCase(c))
End If
Next
Button2_Click
txtinput.Clear()
txtoutput.Clear()
SAMPLE OUTPUT:

LAPC

Page 8

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the program for case conversion was executed and the output was verified.
LAPC

Page 9

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 4

TEXT EDITOR CREATION

AIM:
Develop a menu based VB .NET application to implement a text editor with cut, copy, paste,
save and close operations.
PROCEDURE:
Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005
Select File New Project Windows application.
Open the Windows application.
Place the MenuStrip in the form from tool box.
Main menu is constructed with number of sub menus named as open, close, save, cut,
copy, paste, undo, redo, color, font etc.,
6. Drag and place a RichTextBox in the form.
7. Insert the source code for appropriate menu items and finally run the application.
PROGRAM:
Form_Load
Label1.Visible = False
txtsave.Visible = False
btnsave.Visible = False
1.
2.
3.
4.
5.

NewToolStripMenuItem_Click
RichTextBox1.Clear()
SaveToolStripMenuItem_Click
Label1.Visible = True
txtsave.Visible = True
btnsave.Visible = True
CloseToolStripMenuItem_Click
RichTextBox1.Clear()
CutToolStripMenuItem_Click
RichTextBox1.Cut()
CopyToolStripMenuItem_Click
RichTextBox1.Copy()
PasteToolStripMenuItem_Click
RichTextBox1.Paste()
ExitToolStripMenuItem1_Click
End
btnsave_Click
RichTextBox1.SaveFile(CStr(txtsave.Text))
Label1.Visible = False
txtsave.Visible = False
btnsave.Visible = False
LAPC

Page 10

25257 - .NET PROGRAMMING PRACTICAL


SAMPLE OUTPUT:

RESULT:
Thus the VB.NET application for Text Editor Creation was executed and the output was
verified.
LAPC

Page 11

25257 - .NET PROGRAMMING PRACTICAL

CALCULATOR

Ex.No. : 5

AIM:
Write a program to implement the calculator with memory and recall operations.
PROCEDURE:
1.
2.
3.
4.
5.
6.
7.

Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005


Select File New Project Windows application.
Open the windows application form.
Place fifteen buttons and named as 0 to 9 and operators +, -, *, /, =.
Add another three buttons named as memory, recall, cancel.
Type the code in appropriate events.
Run the application by F5 key or pressing debug button.

PROGRAM:
General
Dim a, m As Integer
Dim o As Char
btn0_Click
txtinput.AppendText("0")
btn1_Click
txtinput.AppendText("1")
btn2_Click
txtinput.AppendText("2")
btn3_Click
txtinput.AppendText("3")
btn4_Click
txtinput.AppendText("4")
btn5_Click
txtinput.AppendText("5")
btn6_Click
txtinput.AppendText("6")
btn7_Click
txtinput.AppendText("7")
btn8_Click
txtinput.AppendText("8")
btn9_Click
txtinput.AppendText("9")
btnadd_Click
a = Val(txtinput.Text)
o = "+"
txtinput.Clear()

LAPC

Page 12

25257 - .NET PROGRAMMING PRACTICAL


btndiv_Click
a = Val(txtinput.Text)
o = "/"
txtinput.Clear()
btnmul_Click
a = Val(txtinput.Text)
o = "*"
txtinput.Clear()
btnsub_Click
a = Val(txtinput.Text)
o = "-"
txtinput.Clear()
btnmemory_Click
m = txtinput.Text
txtinput.Clear()
btnrecall_Click
txtinput.Text = m
btncancel_Click
txtinput.Clear()
btnequal_Click
Select Case o
Case "+"
txtinput.Text = a + Val(txtinput.Text)
Case "-"
txtinput.Text = a - Val(txtinput.Text)
Case "*"
txtinput.Text = a * Val(txtinput.Text)
Case "/"
txtinput.Text = a / Val(txtinput.Text)
End Select
SAMPLE OUTPUT:

LAPC

Page 13

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the above program for calculator was executed and the output was verified.
LAPC

Page 14

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 6

CALENDAR APPLICATION

AIM:
Develop a form in VB .NET to pick a date from calendar control and display the day, month,
year in separate textboxes.
PROCEDURE:
Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005
Select File New Project Windows application.
Open the windows application form.
Place a DateTimePicker to select the date.
Place four label and textboxes named as day, date, month, and year.
Edit the following code in form load event and value changed event of
Datetimepicker.
7. Run the application by pressing F5 key.
1.
2.
3.
4.
5.
6.

PROGRAM:
Form_Load, DateTimePicker1_ValueChanged
txtday.Text = DateTimePicker1.Value.DayOfWeek.ToString
txtdate.Text = DateTimePicker1.Value.Day
txtmonth.Text = DateTimePicker1.Value.Month
txtyear.Text = DateTimePicker1.Value.Year
btnclear_Click
txtday.Clear()
txtdate.Clear()
txtmonth.Clear()
txtyear.Clear()
SAMPLE OUTPUT:

LAPC

Page 15

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the above program for display date, month, and year was executed and output was
verified.
LAPC

Page 16

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 7

QUIZ CREATION

AIM:
Develop a VB .NET application to perform timer based quiz of 10 questions.
PROCEDURE:
Click StartProgramsMicrosoft Visual Studio 2005 Microsoft Visual Studio 2005
Select File New Project Windows application.
Open the windows application form.
Place a TextBox and named as txtquestion.
Place a GroupBox and enter text as Answer.
Within the GroupBox place three RadioButton
Place a Button named as Result.
Then place a Timer and set interval property of timer as 3000.
Insert the code in Form_Load, btnresult,Timer1_Tick and RadioButton_Checked Chenged
event.
10. Run the application by pressing F5 key.
1.
2.
3.
4.
5.
6.
7.
8.
9.

PROGRAM:
General:
Dim quest(9, 3), ans(9, 1) As String
Dim i As Integer = -1
Quiz_Creation_Load:
quest(0, 0) = "Which language does not support .NET?"
quest(0, 1) = "C++"
quest(0, 2) = "C#"
quest(0, 3) = "C"
quest(1, 0) = "Expansion of WSDL is"
quest(1, 1) = "Web Server Description Language"
quest(1, 2) = "Web Service Definition Language"
quest(1, 3) = "Web Service Description Language"
quest(2, 0) = "IIS stands for"
quest(2, 1) = "Internet Information Services"
quest(2, 2) = "Intermediate Information Services"
quest(2, 3) = "Internet Information Server"
quest(3, 0) = "Which one of the Heart of .NET Framework"
quest(3, 1) = "CLR"
quest(3, 2) = "CTS"
quest(3, 3) = "CLS"
quest(4, 0) = "Which tool are used to handle metadata"
quest(4, 1) = "Reflection Tool"
quest(4, 2) = "Manifest Tool"
quest(4, 3) = "All"
quest(5, 0) = "Which one is not a part of .NET Framework"
quest(5, 1) = "Visual Studio.NET"
quest(5, 2) = "Visual Basic .NET"
quest(5, 3) = "ASP.NET"
quest(6, 0) = "ASP Stands for"
LAPC

Page 17

25257 - .NET PROGRAMMING PRACTICAL


quest(6, 1) = "Actual Server Page"
quest(6, 2) = "Active Server Page"
quest(6, 3) = "Active Several Page"
quest(7, 0) = "XML Stands for"
quest(7, 1) = "Extensible Mark Language"
quest(7, 2) = "Extended Markup Language"
quest(7, 3) = "Extensible Markup Language"
quest(8, 0) = "DTD Stands for"
quest(8, 1) = "Dynamic Type Definition"
quest(8, 2) = "Document Type Definition"
quest(8, 3) = "Dynamic Transfer Lanquage"
quest(9, 0) = "SOAP satnds for"
quest(9, 1) = "Simple Oriented Access Protocol"
quest(9, 2) = "Sample Object Access Protocal"
quest(9, 3) = "Simple Object Access Protocol"
ans(0, 0) = "C"
ans(1, 0) = "Web Service Description Language"
ans(2, 0) = "Internet Information Services"
ans(3, 0) = "CLR"
ans(4, 0) = "All"
ans(5, 0) = "Visual Studio.NET"
ans(6, 0) = "Active Server Page"
ans(7, 0) = "Extesible Markup Language"
ans(8, 0) = "Document Type Definition"
ans(9, 0) = "Simple Object Access Protocol"
Timer1.Enabled = True
btnresult.Enabled = False
btnresult_Click
Dim j As Integer
Dim count As Integer = 0
For j = 0 To 9
If (ans(j, 0) = ans(j, 1)) Then
count += 1
End If
Next
MsgBox("You have scored " & count & " Marks")
Timer1_Tick
i=i+1
If (i = 10) Then
Timer1.Enabled = False
btnresult.Enabled = True
RadioButton1.Enabled = False
RadioButton2.Enabled = False
RadioButton3.Enabled = False
txtquestion.Clear()
Else
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
txtquestion.Text = quest(i, 0)
RadioButton1.Text = quest(i, 1)
RadioButton2.Text = quest(i, 2)
RadioButton3.Text = quest(i, 3)
End If
LAPC

Page 18

25257 - .NET PROGRAMMING PRACTICAL

RadioButton1_CheckedChanged:
ans(i, 1) = RadioButton1.Text
RadioButton2_CheckedChanged
ans(i, 1) = RadioButton2.Text
RadioButton3_CheckedChanged
ans(i, 1) = RadioButton3.Text
SAMPLE OUTPUT

LAPC

Page 19

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the VB.NET application for Timer based Quiz was executed and output was verified.
LAPC

Page 20

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 8

FILE AND FOLDER CONTROL

AIM:
Develop a VB .NET application using the File and Directory controls to implement a
common dialog box.
PROCEDURE:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Click Start ProgramsMicrosoft Visual Studio 2005 Microsoft Visual Studio 2005
Select File New Project Windows application.
Open the Windows Application form.
Place FolderBrowserDialog and OpenFileDialog from ToolBox
Place a GroupBox and enter Text as Select the Option.
Within the GroupBox place two RadioButton and enter Text as Folder Open, File Open.
Place a Button named as OK.
Place two LabelBox and TextBox from the ToolBox.
Insert the code in click event of btnok.
Run the application by pressing F5 key.

PROGRAM:
btnok_Click
If RadioButton1.Checked = True Then
FolderBrowserDialog1.ShowDialog()
txtfolder.Text = FolderBrowserDialog1.SelectedPath
Else
OpenFileDialog1.ShowDialog()
txtfile.Text = OpenFileDialog1.FileName
End If
SAMPLE OUTPUT

LAPC

Page 21

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the VB.NET application was executed and output was verified.
LAPC

Page 22

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 9

DATABASE CREATION USING ADO.NET

AIM:
Develop a Database application to store the details of students using ADO.NET.
PROCEDURE:
1. Click Start Programs Microsoft SQL Server SQL Server Management Studio
Express.
2. Then creating database by right clicking the database folder.
3. Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
4. Select File New Project Windows application.
5. Open the Windows application form.
6. Design a form with three LabelBox,three TextBox and a Button.
7. Type the source code in the button event.
8. Run the application by pressing F5 key.
Query:
create database student
use student
create table stud(regno varchar(10), sname varchar(10), dept varchar(10));
Source Code:
Imports System.Data.SqlClient
General
Dim con As New SqlConnection
Dim com As New SqlCommand
Database_Creation_Load
con.ConnectionString = "server=sys19;initial catalog=student; uid=sa; pwd="
con.Open()
com.Connection = con
btnstore_Click
If txtregno.Text = "" Or txtname.Text = "" Or txtdept.Text = "" Then
MsgBox("Please Fill All the Details")
Exit Sub
End If
com.CommandText = "insert into stud values(' " & txtregno.Text & " ',' " & txtname.Text & " ',
' " & txtdept.Text & " ' ) "
com.ExecuteNonQuery()
MsgBox("1 Row inserted Successfully")
txtregno.Clear()
txtname.Clear()
txtdept.Clear()
LAPC

Page 23

25257 - .NET PROGRAMMING PRACTICAL

SAMPLE OUTPUT:

LAPC

Page 24

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the Database application to store the details of students using ADO.NET was
created and executed successfully.
LAPC

Page 25

25257 - .NET PROGRAMMING PRACTICAL

DATABASE UPDATION USING ADO.NET

Ex.No. : 10

AIM:
Develop a Database application using ADO.NET to insert, modify, update and delete
operations.
PROCEDURE:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Click Start Programs Microsoft SQL Server Query Analyzer.


Create new database and then create table.
Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
Select File New Project Windows application.
Open the Windows application form.
Place a GroupBox and enter Text as Select the Option.
Within the GroupBox place two RadioButton and enter Text as Insert, View.
Design a form with three LabelBox,three TextBox,three Button and ComboBox.
Type the source code in the corresponding event control.
Run the application by pressing F5 key.

Query:
create database student
use student
create table stud(regno varchar(10), sname varchar(10), dept varchar(10));
Source Code:
Imports System.Data.SqlClient
General
Dim con As New SqlConnection
Dim com As New SqlCommand
Dim rd As SqlDataReader
Database_Updation_Load
con.ConnectionString = "initial catalog=student; user id=sa;pwd="
con.Open()
com.Connection = con
RadioButton1_CheckedChanged
txtregno.Clear()
txtname.Clear()
txtdept.Clear()
LAPC

Page 26

25257 - .NET PROGRAMMING PRACTICAL


ComboBox1.Visible = False
btninsert.Enabled = True
btnupdate.Enabled = False
btndelete.Enabled = False
RadioButton2_CheckedChanged
ComboBox1.Items.Clear()
btninsert.Enabled = False
btnupdate.Enabled = True
btndelete.Enabled = True
ComboBox1.Visible = True
com.CommandText = "select * from stud"
rd = com.ExecuteReader
While rd.Read
ComboBox1.Items.Add(rd.GetString(0))
End While
rd.Close()
ComboBox1_SelectedIndexChanged
com.CommandText = "select * from stud where regno= ' " & ComboBox1.SelectedItem & " ' "
rd = com.ExecuteReader
If rd.Read Then
txtname.Text = rd.GetString(1)
txtdept.Text = rd.GetString(2)
End If
rd.Close()
btninsert_Click
If txtregno.Text = "" Or txtname.Text = "" Or txtdept.Text = "" Then
MsgBox("Plese fill all the Details")
Exit Sub
End If
com.CommandText = " insert into stud values ( ' " & txtregno.Text & " ' , ' " & txtname.Text & " ' ,
' " & txtdept.Text & " ' ) "
com.ExecuteNonQuery()
MsgBox("1 Record Inserted")
btnupdate_Click
com.CommandText= "update stud set sname= ' " & txtname.Text & " ' , dept= ' " & txtdept.Text & " '
where regno= ' " & ComboBox1.SelectedItem & " ' "
com.ExecuteNonQuery()
MsgBox("Record Updated")
btndelete_Click
com.CommandText = "delete from stud where regno= ' " & ComboBox1.SelectedItem & " ' "
com.ExecuteNonQuery()
ComboBox1.Items.Remove(ComboBox1.SelectedItem)
txtname.Clear()
txtdept.Clear()
MsgBox("Record Deleted")
LAPC

Page 27

25257 - .NET PROGRAMMING PRACTICAL

btnclear_Click
txtregno.Clear()
txtname.Clear()
txtdept.Clear()

SAMPLE OUTPUT
Insertion

Deletion

Updation

LAPC

Page 28

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the Database application using ADO.NET to insert, modify, update and delete
operations was created and executed successfully.
LAPC

Page 29

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 11

TABLE VIEW USING DATAGRID

AIM:
Develop a VB.NET application using Datagrid to display record.
PROCEDURE:
1. Create a table using SQL Server Query Analyzer name stud which the following
columns.
Column Name
Data Type
regno
varchar(50)
name
varchar(50)
dept
varchar(50)
2. Insert the values into the table by using following query.
insert into stud values('101','Sree','Computer')
insert into stud values('102','Poomi','Computer')
insert into stud values('103','Laya','Computer')
insert into stud values('104','Bharathi','Computer')
3. Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
4. Select File New Project Windows application.
5. Open the Windows application form.
6. Select Data Add New Data Source.
7. Choose DatabaseNextNew Connection.
8. Enter the Server name(Ex. Sys19].
9. Then select Use SQL Server Authentication from Log on the Server.
10. Type User name as sa
11. From the Connect to a Database, click Select or enter a database name.
12. Select corresponding Database. Then Click OkNext
13. Select the Checkbox TablesFinish.
14. Place the DataGridView from ToolBox.
15. Select Choose Data Source Add Project Data Source DatabaseNextNext
Table Finish.
16. Run the application by pressing F5 key.
SAMPLE OUTPUT

LAPC

Page 30

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the .VBNET application using Datagrid to display record was created and executed
successfully.
LAPC

Page 31

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 12

DATABASE UPDATION USING DATAGRID

AIM:
Develop a VB.NET application using Datagrid to add, edit, and modify records.
PROCEDURE:
1. Create a table using SQL Server Query Analyzer name stud which the following
columns.
Column Name
Data Type
regno
varchar(50)
name
varchar(50)
dept
varchar(50)
2. Insert the values into the table by using following query.
insert into stud values('101','Sree','Computer')
insert into stud values('102','Poomi','Computer')
insert into stud values('103','Laya','Computer')
insert into stud values('104','Bharathi','Computer')
3. Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
4. Select File New Project Windows application.
5. Open the Windows application form.
6. Place a DataGridView and three Button in the form.
7. Make a Database connection using connection string.
8. By using SQL Adapter and Dataset to fill the records in the DataGridView.
9. Then perform insert, update and delete function in the DataGridView.
10. Run the application using F5 key.
Source Code:
Imports System.Data.SqlClient
General
Dim con As New SqlConnection
Dim com As New SqlCommand
Dim da As SqlDataAdapter
Dim ds As New DataSet
Database_Updation_Datagrid_Load
con.ConnectionString = "initial catalog=student; user id=sa;pwd="
con.Open()
com.Connection = con
da = New SqlDataAdapter("SELECT * FROM STUD", con)
da.Fill(ds, "STUD")
DataGridView1.DataSource = ds.Tables("STUD")
btninsert_Click
com.Connection = con
com.CommandText =" insert into stud values( ' " &DataGridView1.CurrentRow.Cells(0).Value & " '
, ' " & DataGridView1.CurrentRow.Cells(1).Value & " ' , ' "
&DataGridView1.CurrentRow.Cells(2).Value & " ' ) "
com.ExecuteNonQuery()
MsgBox("RECORD INSERTED")
LAPC

Page 32

25257 - .NET PROGRAMMING PRACTICAL


btnupdate_Click
com.Connection = con
com.CommandText =" update stud set sname= ' " & DataGridView1.CurrentRow.Cells(1).Value &" '
, dept = ' " & DataGridView1.CurrentRow.Cells(2).Value & " ' where regno= ' " &
DataGridView1.CurrentRow.Cells(0).Value & " ' "
com.ExecuteNonQuery()
DataGridView1.Refresh()
MsgBox("RECORD UPDATED")
btndelete_Click
com.Connection = con
com.CommandText = "delete from stud where regno= ' "
&DataGridView1.CurrentRow.Cells(0).Value & " ' "
com.ExecuteNonQuery()
DataGridView1.Refresh()
MsgBox("RECORD DELETED")
ds.Clear()
da = New SqlDataAdapter("select * from stud", con)
da.Fill(ds, "stud")
DataGridView1.DataSource = ds.Tables("stud")
SAMPLE OUTPUT
Insertion

Deletion

Updation

After Deletion

LAPC

Page 33

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the .VBNET application using Datagrid to add, edit, and modify records was executed
successfully.
LAPC

Page 34

25257 - .NET PROGRAMMING PRACTICAL

Part-B
ASP.Net and XML Programming

LAPC

Page 35

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 1

SIMPLE WEB PAGE CREATION USING ASP.NET

AIM:
Create a simple ASP.NET page to Output Text with a Form, two HTML Text Boxes, an
HTML button, and an HTML <span> element. Create an event procedure for the button.
PROCEDURE:
1. Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
2. Select File New Web site ASP.NET Web Site.
3. Then the Default.aspx page will be open and select the source tab.
4. Write the html coding within a <form> tag to create two textboxes and a button using
<input> tag.
5. Using <span> tag message can be displayed.
6. Run the application using F5 key.
SOURCE CODE:
<%@
Page
Language="VB"
AutoEventWireup="false"
CodeFile="Website_Creation.aspx.vb" Inherits="Website_Creation" %>
<!DOCTYPE
html
PUBLIC
"-//W3C//DTD
XHTML
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

1.0

Transitional//EN"

<script runat ="server" >


Sub click(ByVal s As Object, ByVal e As EventArgs)
If (Yourname.Value = "Laya" And pass.Value = "Computer") Then
MsgBox("Valid User")
Else
MsgBox("Invalid User")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Simple Web Page Creation</title>
</head>
<body>
<form id="form1" method ="get" runat="server">
<span id="message" runat ="server" >
User Name: <input id="Yourname" runat ="server" type ="text" /><br /><br />
Password: <input id="pass" runat ="server" type ="password" /><br /><br />
<button id="button" runat ="server" type ="button" onserverclick="click" >Submit</button>
</span>
</form>
</body>
</html>

LAPC

Page 36

25257 - .NET PROGRAMMING PRACTICAL

SAMPLE OUTPUT:

LAPC

Page 37

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the creation of simple ASP.NET page using HTML controls was created and output
was verified.
LAPC

Page 38

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 2

HOTEL RESERVATION USING ASP.NET

AIM:
Create a web application in ASP.NET using three different controls to the ASP.NET page for
reserving rooms in hotel. The Three controls are a button control, a label control and drop-down list
control.
PROCEDURE:
1.
2.
3.
4.
5.
6.

Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
Select File New Web site ASP.NET Web Site.
Then the Default.aspx page will be open and select the Design tab.
Construct form with Text box, DropDownList, Button and Label.
Then insert the code in the Source tab for appropriate click event.
Run the website application using F5 key.

Source Code:
<%@ 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">
<script runat ="server" >
Sub page_load(ByVal s As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim i As Integer
For i = 1 To 10
DropDownList1.Items.Add(i)
Next
End If
Label1.Visible = False
End Sub
Sub Reserve_Click(ByVal s As Object, ByVal e As EventArgs)
Label1.Visible = True
Label1.Text = "The Room Reserved for " & TextBox1.Text & " is " & DropDownList1.Text
DropDownList1.Items.Remove(DropDownList1.Text)
If DropDownList1.Items.Count = 0 Then
Button1.Enabled = False
Label1.Text = "Room not available"
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
LAPC

Page 39

25257 - .NET PROGRAMMING PRACTICAL


<title>Hotel Reservation</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Name :
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 104; left: 148px; position:
absolute; top: 13px"></asp:TextBox> <br /> <br /> <br />
Room Number :
<asp:DropDownList ID="DropDownList1" runat="server" Style="z-index: 101; left: 156px;
position: absolute; top: 67px">
</asp:DropDownList> <br /> <br /> <br /><br />
<asp:Button ID="Button1" runat="server" Height="30px" Style="z-index: 102; left: 70px;
position: absolute; top: 121px" Text="Reserve Room" OnClick ="Reserve_Click"
Width="109px" />
<asp:Label ID="Label1" runat="server" Style="z-index: 103; left: 88px; position: absolute;
top: 188px" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
SAMPLE OUTPUT:

LAPC

Page 40

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the web application for Hotel Reservation using ASP.NET was created and executed
successfully.
LAPC

Page 41

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 3

DATABASE ACCESS USING STORED PROCEDURE

AIM:
Create an application for Accessing a SQL Database by using ADO.NET by connecting to the
SQL Server database and call a stored procedure. You then display the data in a Repeater control.
PROCEDURE:
1. Click Start Programs Microsoft SQL Server 2005 SQL Server Management
Studio Access.
2. Create a new database.
3. Create a table and insert the values into the table.
4. Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
5. Select File New Web site ASP.NET Web Site.
6. Select View Server Explorer.
7. In Server Explorer select Data Connections and expand it.
8. Right click the Stored Procedure in the Data Connections tab and click Add New Stored
Procedure.
9. Type the query in the code editor window and run the code by select Project Run.
10. Then type the code in the Source tab.
11. Run the website application using F5 key.
Source Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<%@ Import Namespace="system.data.sqlclient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat ="server">
Dim con As New sqlconnection
Dim com As New SqlCommand("sp1", con)
Dim rd As SqlDataReader
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
con.ConnectionString = "server=sys19; initial catalog=student1; uid=sa;pwd="
con.Open()
com.Connection = con
com.CommandType = Data.CommandType.StoredProcedure
rd = com.ExecuteReader
rp.DataSource = rd
rp.DataBind()
End Sub
</script>

LAPC

Page 42

25257 - .NET PROGRAMMING PRACTICAL


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Database Access Using Stored Procedure</title>
</head>
<body>
<form id="form1" runat="server">
Reg.No Name Dept <br /><br />
<asp:Repeater ID="rp" runat="server">
<ItemTemplate>
<%#container.DataItem("REGNO") %>
<%#Container.DataItem("NAME")%>
<%#container.DataItem("DEPT") %><br />
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
Stored Procedure:
ALTER procedure sp1
as
select * from stud1
return

SAMPLE OUTPUT:

LAPC

Page 43

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus the program for creating the application with Stored Procedure and Repeater Control
was executed successfully.
LAPC

Page 44

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 4

XML WITH ASP.NET

AIM:
Develop a web application to read the details of the selected country stored in XML database
and display back to the user using Web controls.
PROCEDURE:
1.
2.
3.
4.
5.
6.
7.

Create an XML file using Notepad or other editor and save the file as country.xml.
Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
Select File New Web site ASP.NET Web Site.
Then the Default.aspx page will be open and select the Design tab.
Drag the GridView and XmlDataSource control from the ToolBox.
Type the code in the source tab.
Run the website application using F5 key.

Country.XML
<?xml version="1.0"?>
<country>
<coun countryname="India"> </coun>
<coun countryname="Japan"></coun>
<coun countryname="China"></coun>
</country>
Source code:
<%@ Page Language="VB"%>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>XML With ASP.NET</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false" DataSourceID
="xmldatasource1">
<Columns >
<asp:BoundField DataField ="countryname" HeaderText ="CountryName" SortExpression
="CountryName" />
</Columns>
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile ="C:\Documents and
Settings\Acer\My Documents\Kanaga\country.xml" XPath ="country/coun">
</asp:XmlDataSource>
</form>
</body>
</html>
LAPC

Page 45

25257 - .NET PROGRAMMING PRACTICAL


SAMPLE OUTPUT:

RESULT:
Thus web application for XML with ASP.NET was created and executed successfully.
LAPC

Page 46

25257 - .NET PROGRAMMING PRACTICAL

Ex.No. : 5

XML WITH DATASET

AIM:
Develop a web application to read an XML document containing subject, mark scored, and
year of passing into a Dataset.
PROCEDURE:
1. Create an XML file using Notepad or other editor and save the file as Mark.xml.
2. Click Start Programs Microsoft Visual Studio 2005 Microsoft Visual Studio 2005
3. Select File New Web site ASP.NET Web Site.
4. Then the Default.aspx page will be open and select the Design tab.
5. Drag the GridView control into the form.
6. Type the code in the Source tab.
7. Run the website application using F5 key.
Mark.xml:
<?xml version=1.0?>
<students>
<student>
<name>Laya</name>
<subject>.NET Programming</subject>
<mark>100</mark>
<year>2013</year>
</student>
<student>
<name>Sree</name>
<subject>Web Programming</subject>
<mark>100</mark>
<year>2013</year>
</student>
<student>
<name>Govi</name>
<subject>RDBMS</subject>
<mark>100</mark>
<year>2013</year>
</student>
<student>
<name>Mancy</name>
<subject>Advanced Computing</subject>
<mark>100</mark>
<year>2013</year>
</student>
</students>
LAPC

Page 47

25257 - .NET PROGRAMMING PRACTICAL

Source Code:
<%@ Page Language="VB" %>
<%@ Import Namespace ="system.data" %>
<script runat ="server" >
Protected Sub page_load()
Dim data As New DataSet
data.ReadXml(MapPath("Mark.xml"))
GridView1.DataSource = data
GridView1.DataBind()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>XML With DataSet</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>
SAMPLE OUTPUT:

LAPC

Page 48

25257 - .NET PROGRAMMING PRACTICAL

RESULT:
Thus web application for XML with Dataset was created and executed successfully.

LAPC

Page 49

25257 - .NET PROGRAMMING PRACTICAL

Beyond Syllabus

LAPC

Page 50

25257 - .NET PROGRAMMING PRACTICAL

LAPC

Page 51

25257 - .NET PROGRAMMING PRACTICAL

LAPC

Page 52

25257 - .NET PROGRAMMING PRACTICAL

LAPC

Page 53

25257 - .NET PROGRAMMING PRACTICAL

LAPC

Page 54

25257 - .NET PROGRAMMING PRACTICAL

LAPC

Page 55

Potrebbero piacerti anche