Escolar Documentos
Profissional Documentos
Cultura Documentos
Computer Engineering
Prepared By,
M. Suganthi B.Tech.,
Lecturer/ CT.
.Net Programming
(V-Sem)
Computer Engineering
CONSOLE APPLICATION
Ex.No: 1
Date:
Aim:
To accept a character from console and to check the case of the character.
Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).
4. After opening the console application form write the source code.
5. Then convert the Uppercase to Lowercase and Lowercase to Uppercase with the function
of Ucase and Lcase.
(V-Sem)
Computer Engineering
Source Code:
Module Module1
Sub Main()
Dim c As Char
Console.WriteLine("Enter the character")
c = Console.ReadLine
If Asc(c) > 64 And Asc(c) < 91 Then
Console.WriteLine("UPPERCASE")
ElseIf Asc(c) > 96 And Asc(c) < 122 Then
Console.WriteLine("LOWERCASE")
Else
Console.WriteLine("Other character")
End If
Console.ReadLine()
End Sub
End Module
RESULT:
Thus the above program for checking the case of the character was executed successfully and the
output was verified.
.Net Programming
(V-Sem)
Computer Engineering
VOWELS
Ex.No: 2
Date:
Aim:
Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).
3. Open the window application form, and then place the label, Textbox and button in the
form.
4. Insert the code for Button Click Event procedure using IF statement to check whether the
character is vowel or not.
.Net Programming
(V-Sem)
Computer Engineering
Source Code:
Public Class exp2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim d As Char
d = UCase(TextBox1.Text)
If d = "A" Or d = "E" Or d = "I" Or d = "O" Or d = "U" Then
TextBox2.Text = "Its a vowel"
Else
TextBox2.Text = "Not a vowel"
End If
End Sub
End Class
RESULT:
Thus the above program for displaying whether the given character is vowel or not was executed
successfully and the output was verified.
.Net Programming
(V-Sem)
Computer Engineering
CASE CONVERSION
Ex.No: 3
Date:
Aim:
Write a VB.Net program to accept a string and convert the case of the characters.
Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).
3. Open the window application form, and then place the label, Textbox and button in the
4. Insert the code to convert the Uppercase to Lowercase and Lowercase to Uppercase with
the function of Ucase and Lcase.
(V-Sem)
Computer Engineering
Source Code:
Public Class exno3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim st As Integer
st = String.Compare(TextBox1.Text, UCase(TextBox1.Text))
If st = 0 Then
TextBox2.Text = LCase(TextBox1.Text)
MsgBox("The Lower case is:" & TextBox2.Text)
Else
TextBox2.Text = UCase(TextBox1.Text)
MsgBox("The Upper case is:" & TextBox2.Text)
End If
End Sub
End Class
RESULT:
Thus the above program for converting the case of the string was executed successfully and the
output was verified.
.Net Programming
(V-Sem)
Computer Engineering
Ex.No: 4
Date:
Aim:
Develop a menu based VB.Net application to implement a text editor with cut, copy,
paste, save and close operations.
Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
3. ASP.Net
4. SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
.Net Programming
(V-Sem)
Computer Engineering
Source Code:
Public Class Form1
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenToolStripMenuItem.Click
OpenFileDialog1.DefaultExt = "*.txt"
OpenFileDialog1.Filter = "Text Files|*.txt"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) And
OpenFileDialog1.FileName.Length > 0 Then
RichTextBox1.LoadFile(OpenFileDialog1.FileName,
RichTextBoxStreamType.PlainText)
End If
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CutToolStripMenuItem.Click
RichTextBox1.Cut()
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CopyToolStripMenuItem.Click
RichTextBox1.Copy()
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PasteToolStripMenuItem.Click
RichTextBox1.Paste()
End Sub
Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SelectAllToolStripMenuItem.Click
RichTextBox1.SelectAll()
End Sub
Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles UndoToolStripMenuItem.Click
RichTextBox1.Undo()
End Sub
Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RedoToolStripMenuItem.Click
RichTextBox1.Redo()
End Sub
.Net Programming
(V-Sem)
Computer Engineering
(V-Sem)
Computer Engineering
CALCULATOR
Ex.No: 5
Date:
Aim:
Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
4. Construct the form with ten buttons for digits, four buttons for operator, one button for
memory recalling, one button for save to memory, one button for unsaved to memory.
5. Then insert the separate source code for digits, operator, memory recalling, memory
saved, unsaved and calculations.
(V-Sem)
Computer Engineering
Source Code:
Public Class Form1
Dim a, m As Integer
Dim op As Char
Dim kk As String
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button15.Click
TextBox1.Clear()
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button16.Click
m = Val(TextBox1.Text)
TextBox1.Clear()
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button17.Click
TextBox1.Text = m
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
TextBox1.AppendText("1")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button2.Click
TextBox1.AppendText("2")
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button3.Click
TextBox1.AppendText("3")
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button4.Click
TextBox1.AppendText("4")
End Sub
.Net Programming
(V-Sem)
Computer Engineering
.Net Programming
(V-Sem)
Computer Engineering
RESULT:
Thus the above program for calculator control was executed successfully and the output was
verified.
.Net Programming
(V-Sem)
Computer Engineering
CALENDAR
Ex.No: 6
Date:
Aim:
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.
Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
.Net Programming
(V-Sem)
Computer Engineering
Source Code:
Public Class Form1
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles DateTimePicker1.ValueChanged
TextBox1.Text = DateTimePicker1.Value.Day
TextBox2.Text = DatePart(DateInterval.Month, DateTimePicker1.Value)
TextBox3.Text = DateTimePicker1.Value.Year
TextBox4.Text = DateTimePicker1.Value.Hour
End Sub
End Class
RESULT:
Thus the above program for displaying the date, time using calendar control was executed
successfully.
.Net Programming
(V-Sem)
Computer Engineering
Ex.No: 7
Date:
Aim:
Source Code:
.Net Programming
(V-Sem)
Computer Engineering
(V-Sem)
Computer Engineering
RESULT:
Thus the above program for timer based quiz was executed successfully and the output was
verified .
Ex.No: 8
.Net Programming
Computer Engineering
Date:
Aim:
Develop a VB.NET application using the File, Directory and drive controls to
implement a common dialog box.
Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).
2. Select File New Project window application.Open the window application form.
3. Place the Drive List Box, Directory List Box, File List Box, Textbox, Button from the
Toolbox.
4. Insert the code for selected Index Changed event in the Drive, Directory, File listbox.
5. Then place the image at run time for Button click event.
6. Finally run the window application.
Source Code:
Public Class expno8
.Net Programming
(V-Sem)
Computer Engineering
RESULT:
Thus the above program for implementing file, directory and drive control was executed
successfully and the output was verified.
Ex.No: 9
Date:
.Net Programming
(V-Sem)
Computer Engineering
Aim:
Develop a database application to store the details of students using ADO.NET.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the window application form.
2. Construct the form with labels, textboxes and button from toolbox.
3. First add new record to the existing table for click event. That is all the textboxes are set
to clear.
4. Then insert the new record using Data Bindings method to text property of the textbox
control and to fetch the data from the field in the table.
5. With the use of ExecuteNonQuery method of OleDb Command to insert new record to
the table and after inserting, databindings related to all textboxes are cleared.
6. The ExecuteNonQuery() method sends the SQL command to the Database server.
7. Then call in our My dataset dataset object.
8. After inserting the new record then identify the current position with the help of
mybind.position.
9. Then delete the existing record from the table with the help of ExecuteNonQuery string
command, updated from the table with the OleDbDataAdapter.
10. Finally run the application.
Source Code:
Imports System.Data.SqlClient
Public Class Form1
Dim bm As BindingManagerBase
.Net Programming
(V-Sem)
Computer Engineering
(V-Sem)
Computer Engineering
1. Open the SQL server 2000 Enterprise manager SQL server group local windows
NT database.
2. Create a new database with the name stu to store the student information.
3. Right click the database, and select new table to create a new table named as stud.
Create
Create table stud(name varchar(15), rollno int, branch varchar(10), year int)
Insert
Insert into stud values(amar,1501,cse,2)
Display
Select * from stud
RESULT:
Thus the above program for displaying the records using ADO.NET was executed successfully
and the output was verified.
.Net Programming
(V-Sem)
Computer Engineering
Ex.No: 10
Date:
Aim:
Develop a database application using ADO.NET to insert, modify, update and delete
operations.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the window application form.
2. Construct the form with labels, textboxes and button from toolbox.
3. First add new record to the existing table for click event. That is all the textboxes are set
to clear.
4. Then insert the new record using Data Bindings method to text property of the textbox
control and to fetch the data from the field in the table.
5. With the use of ExecuteNonQuery method of OleDb Command to insert new record to
the table and after inserting, databindings related to all textboxes are cleared.
6. The ExecuteNonQuery() method sends the SQL command to the Database server.
7. Then call in our My dataset dataset object.
8. After inserting the new record then identify the current position with the help of
mybind.position.
9. Then delete the existing record from the table with the help of ExecuteNonQuery string
command, updated from the table with the OleDbDataAdapter.
10. Finally run the application.
.Net Programming
(V-Sem)
Computer Engineering
DataSet:
1. To generate the dataset, right click the Oledb DataAdapter
2. Then appear the generate DataSet window then choose the table to be added with the
DataSet then press OK button.
3. Then place the new dataset in the form.
.Net Programming
(V-Sem)
Computer Engineering
Source Code:
Imports System.Data.SqlClient
Public Class exno10
Dim con As New SqlConnection
Dim ada As New SqlDataAdapter
Dim ds As New DataSet
Dim cmd As New SqlCommand
Dim bm As BindingManagerBase
Dim dr As SqlDataReader
Private Sub exno10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
con.ConnectionString = "Data Source=PRAKASH-A6DC00A;Initial
Catalog=stu;Integrated Security=true"
con.Open()
ada = New SqlDataAdapter("select * from stud", con)
ada.Fill(ds, "stud")
TextBox1.DataBindings.Add("text", ds, "stud.name")
TextBox2.DataBindings.Add("text", ds, "stud.rollno")
TextBox3.DataBindings.Add("text", ds, "stud.branch")
TextBox4.DataBindings.Add("text", ds, "stud.year")
bm = Me.BindingContext(ds, "stud")
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
cmd = New SqlCommand("insert into stud values('" + TextBox1.Text + "'," +
TextBox2.Text + ",'" + TextBox3.Text + "'," + TextBox4.Text + ")", con)
cmd.ExecuteNonQuery()
MsgBox("Record added successfully!!!")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button2.Click
cmd = New SqlCommand("delete from stud where rollno=" + TextBox2.Text + " ", con)
cmd.ExecuteNonQuery()
MsgBox("Record deleted successfully")
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button3.Click
cmd = New SqlCommand(" update stud set name='" + TextBox1.Text + "',branch='" +
TextBox3.Text + "', year=" + TextBox4.Text + "where rollno=" + TextBox2.Text + "", con)
.Net Programming
(V-Sem)
Computer Engineering
cmd.ExecuteNonQuery()
MsgBox("Record Is updated")
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button4.Click
Try
cmd = New SqlCommand("select * from stud where rollno=" + TextBox2.Text + "", con)
dr = cmd.ExecuteReader
dr.Read()
TextBox1.Text = dr(0)
TextBox3.Text = dr(2)
TextBox4.Text = dr(3)
dr.Close()
Catch ex As Exception
MsgBox("Record not found")
dr.Close()
End Try
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub
End Class
RESULT:
Thus the above program for performing insert, delete, update and search operations using
ADO.NET was executed successfully and the output was verified.
.Net Programming
(V-Sem)
Ex.No: 11
Computer Engineering
Date:
Aim:
Develop a VB.Net application using Datagrid to display records.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the window application form.
2. Place the DtaGrid from toolbox.
3. Then create OleDb DataAdapter, connection and DataSet.
4. After creation of Adapter then open the property of the DataGrid , we can set the Data
source and Data member.
5. Then insert the code in the Form load event.
6. Then run the application to give student information through the grid.
DataAdapter Configuration Wizard and Connection:
1. In the Toolbox, select the data tab, Drag an OleDb DataAdapter on to the design interface
of the component.
2. Now open the DataAdapter configuration wizard then choose your new Data Connection
then click Next button.
3. Then Data Link properties window appeared.
4. In Data Link properties, First tab select the name of the provider, second tab select the
connection, i.e., select the name of the server, user name, database name.
5. Then press the test connection button to check if we have correctly configured the
connection.
.Net Programming
(V-Sem)
Computer Engineering
DataSet:
1. To generate the dataset, right click the Oledb DataAdapter
2. Then appear the generate DataSet window then choose the table to be added with the
DataSet then press OK button.
3. Then place the new dataset in the form.
.Net Programming
(V-Sem)
Computer Engineering
Source Code:
Imports System.Data.SqlClient
Public Class Form1
Dim con As New SqlConnection
Dim ada As New SqlDataAdapter
Dim ds As New DataSet
Dim cmd As New SqlCommand
Dim bm As BindingManagerBase
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
con.ConnectionString = "Data Source=PRAKASH-A6DC00A;Initial
Catalog=stu;Integrated Security=true"
con.Open()
ada = New SqlDataAdapter("select * from stud", con)
ada.Fill(ds, "stud")
DataGridView1.DataSource = ds.Tables(0)
bm = Me.BindingContext(ds, "stud")
End Sub
End Class
RESULT:
Thus the above program for displaying records using DataGrid view was executed successfully
and the output was verified.
.Net Programming
(V-Sem)
Computer Engineering
Date:
Aim:
Develop a VB.Net application using Datagrid to add, edit and modify records.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the window application form.
2. Place the DtaGrid, button from toolbox.
3. Then create OleDb DataAdapter, connection and DataSet.
4. After creation of Adapter then open the property of the DataGrid , we can set the Data
source and Data member.
5. Then insert the code in the Form load event.
6. Then run the application to edit, delete the student information through the grid.
DataAdapter Configuration Wizard and Connection:
1. In the Toolbox, select the data tab, Drag an OleDb DataAdapter on to the design interface
of the component.
2. Now open the DataAdapter configuration wizard then choose your new Data Connection
then click Next button.
3. Then Data Link properties window appeared.
4. In Data Link properties, First tab select the name of the provider, second tab select the
connection, i.e., select the name of the server, user name, database name.
5. Then press the test connection button to check if we have correctly configured the
connection.
6. Then press Ok button to create the connection.
.Net Programming
(V-Sem)
Computer Engineering
7. Then the Query type window will appear, we have to select the data adapter by using
SQL statements or stored procedures.
8. Then press the Next button, the screen appears called as generate the SQL statements.
9. In this window, the SQL command can be typed manually or we can form command
through the SQL Query Builder(Select the Query builder button).
10. On the first dialog that appears, select the table name and press the Add button, and then
press close.
11. After selecting OK button, the resulting screen appears i.e., top of the box in the Query
builder window, list the columns in the table, then check all the columns, then press OK
button.
12. After the completion of Query Builder, press the Next button, then appears the View
Wizard results to generate the OleDb DataAdapter was configured successfully.
DataSet:
1. To generate the dataset, right click the Oledb DataAdapter
2. Then appear the generate DataSet window then choose the table to be added with the
DataSet then press OK button.
3. Then place the new dataset in the form.
.Net Programming
(V-Sem)
Computer Engineering
Source Code:
Imports System.Data.SqlClient
Public Class Form1
Dim con As New SqlConnection
Dim ada As New SqlDataAdapter
Dim ds As New DataSet
Dim cmd As New SqlCommand
Dim bm As BindingManagerBase
Dim dr As SqlDataReader
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Try
con.ConnectionString = "Data Source=PRAKASH-A6DC00A;Initial
Catalog=stu;Integrated Security=true"
con.Open()
ada = New SqlDataAdapter("select * from stud", con)
ada.Fill(ds, "stud")
DataGridView1.DataSource = ds.Tables(0)
TextBox1.DataBindings.Add("text", ds, "stud.name")
TextBox2.DataBindings.Add("text", ds, "stud.rollno")
TextBox3.DataBindings.Add("text", ds, "stud.branch")
TextBox4.DataBindings.Add("text", ds, "stud.year")
bm = Me.BindingContext(ds, "stud")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
cmd.Connection = con
cmd = New SqlCommand("insert into stud values('" + TextBox1.Text + "'," +
TextBox2.Text + ",'" + TextBox3.Text + "'," + TextBox4.Text + ")", con)
cmd.ExecuteNonQuery()
MsgBox("Record added successfully!!!")
End Sub
.Net Programming
(V-Sem)
Computer Engineering
RESULT:
Thus the above program for updating records using DataGrid view was executed successfully
and the output was verified.
.Net Programming
(V-Sem)
Computer Engineering
Ex.No: 13
Date:
Aim:
Create a simple ASP.NET page to output Text with a form, two HTML textboxes, a
HTML button, and an HTML<span> element. Create an event procedure for the button.
Apparatus Required:
Software Required: DotNet Framework,
ASP.Net
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
3. Construct form with button, textboxes, List Box and Drop Down List from toolbox.
4. Set the property Autopostback as true for List Box and Drop down list.
.
5. Then insert the code in the View code Window for appropriate click event program
(V-Sem)
Computer Engineering
Source Code:
Public Class _Default
Inherits System.Web.UI.Page
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles
Button1.Click
TextBox1.Text = "Welcome to Temple City"
End Sub
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DropDownList1.SelectedIndexChanged
TextBox2.Text = "You have selected the color:" &
_DropDownList1.SelectedItem.Value.ToString
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox2.Text = "You have selected the subject:" &
_ListBox1.SelectedItem.Value.ToString
End Sub
End Class
RESULT:
Thus the above program for creating a simple ASP.NET page was executed successfully and the
output was verified.
.Net Programming
(V-Sem)
Ex.No: 14
Computer Engineering
Date:
Aim:
Create a web controls to a page with 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.
Apparatus Required:
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
3. Construct form with button, Label and Drop Down List boxes from toolbox.
4. Then insert the code in the View code Window for appropriate click event program
.Net Programming
(V-Sem)
Computer Engineering
Source Code:
Public Partial Class WebForm2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
Label1.Visible = False
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
Label1.Visible = True
Label1.Text = DropDownList1.SelectedItem.Text + "is Reserved for you :-)"
DropDownList1.Items.Remove(DropDownList1.SelectedItem.Text)
If DropDownList1.Items.Count = 0 Then
Button1.Enabled = False
End If
End Sub
End Class
RESULT:
Thus the above program for reserving hotel rooms using ASP.NET was executed successfully
and the output was verified.
.Net Programming
(V-Sem)
Ex.No: 15
Computer Engineering
Date:
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. Then to display the data in a
repeater control.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the Web application form.
2. Place the Repeater control from toolbox.
3. Then create OleDb DataAdapter, connection and DataSet.
4. After creation of Adapter then open the property of the DataGrid , we can set the Data
source and Data member.
5. Then insert the code in the Form load event.
6. Then run the application to give student information through the Repeater control.
DataAdapter Configuration Wizard and Connection:
1. In the Toolbox, select the data tab, Drag an OleDb DataAdapter on to the design interface
of the component.
2. Now open the DataAdapter configuration wizard then choose your new Data Connection
then click Next button.
3. Then Data Link properties window appeared.
4. In Data Link properties, First tab select the name of the provider, second tab select the
connection, i.e., select the name of the server, user name, database name.
.Net Programming
(V-Sem)
Computer Engineering
5. Then press the test connection button to check if we have correctly configured the
connection.
6. Then press Ok button to create the connection.
7. Then the Query type window will appear, we have to select the data adapter by using
SQL statements or stored procedures.
8. Then press the Next button, the screen appears called as generate the SQL statements.
9. In this window, the SQL command can be typed manually or we can form command
through the SQL Query Builder(Select the Query builder button).
10. On the first dialog that appears, select the table name and press the Add button, and then
press close.
11. After selecting OK button, the resulting screen appears i.e., top of the box in the Query
builder window, list the columns in the table, then check all the columns, then press OK
button.
12. After the completion of Query Builder, press the Next button, then appears the View
Wizard results to generate the OleDb DataAdapter was configured successfully.
DataSet:
1. To generate the dataset, right click the Oledb DataAdapter
2. Then appear the generate DataSet window then choose the table to be added with the
DataSet then press OK button.
3. Then place the new dataset in the form.
Source Code:
.Net Programming
(V-Sem)
Computer Engineering
Double click the web.config file and write following code in it:
<connectionStrings>
<add name="constr" connectionString="initial catalog=puran; data source=MCN002;
integrated security=sspi"/>
</connectionStrings>
Default.aspx file code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
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">
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" />
<title>Repeater Controls in ASP.NET</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="RepeatInformation" runat="server">
<HeaderTemplate>
<table class="tblcolor">
<tr>
<b>
<td>
Roll No
</td>
<td>
Student Name
</td>
<td>
Total Fees
</td>
</b>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="tblrowcolor">
.Net Programming
(V-Sem)
Computer Engineering
<td>
<%#DataBinder.Eval(Container,"DataItem.RollNo")%>
</td>
<td>
<%#DataBinder.Eval(Container,"DataItem.Name")%>
</td>
<td>
<%#DataBinder.Eval(Container,"DataItem.Fees")%>
</td>
</tr>
</ItemTemplate>
<SeparatorTemplate>
<tr>
<td>
<hr />
</td>
<td>
<hr />
</td>
<td>
<hr />
</td>
</tr>
</SeparatorTemplate>
<AlternatingItemTemplate>
<tr>
<td>
<%#DataBinder.Eval(Container,"DataItem.RollNo")%>
</td>
<td>
<%#DataBinder.Eval(Container,"DataItem.Name")%>
</td>
<td>
<%#DataBinder.Eval(Container,"DataItem.Fees")%>
</td>
</tr>
</AlternatingItemTemplate>
<SeparatorTemplate>
<tr>
<td>
.Net Programming
(V-Sem)
Computer Engineering
<hr />
</td>
<td>
<hr />
</td>
<td>
<hr />
</td>
</tr>
</SeparatorTemplate>
<FooterTemplate>
<tr>
<td>
School Records displayed
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
Code behind file code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
.Net Programming
(V-Sem)
Computer Engineering
{
SqlConnection con;
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
con = new
SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
cmd.Connection = con;
cmd.CommandText = "select * from student";
con.Open();
RepeatInformation.DataSource = cmd.ExecuteReader();
RepeatInformation.DataBind();
con.Close();
}
}
RESULT:
Thus the above program for updating records using ASP.NET was executed successfully and the
output was verified.
Ex.No: 16
.Net Programming
Computer Engineering
Date:
Aim:
Create a web service application for calling a Web service for a hotel named full, and
call another web service for a hotel named Empty, and then retrieve information regarding room
availability. The web service for full hotel is named Hotel_Full.dll. the web service for the hotel
Empty is Hotel_Empty.dll. There are five methods in each service.
1. Reserve takes room types and start and end dates and returns a Boolean value that
indicates whether a room is available. <WebMethod()>public Function Reserve
(strRoomType1 As String, strRoomType2 As String, dtmStartDate As Date, dtmEndDate
As Date) As Boolean
2. Price returns a double value that is the cost of the rent for one day <WebMethod()>public
Function Price(strRoomType1 As String) As Double
3. Description returns a string that describes the hotel. <WebMethod()>public Function
Description() As String
4. Room returns a string that describes the rooms of the hotel. <WebMethod()>public
Function Room() As String
5. Food returns a string that describes the food available at the hotel. <WebMethod()>public
Function Food() As String.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the Visual Basic .NET IDE.
2. Select File New Project Web application to open the new aspx.web service file.
3. Create various functions for performing the operation of Reserve, Price, Rooms,
Description and Food.
4. Then write the code in the coding window.
5. Finally, run the web service to produce output.
Web Service:
.Net Programming
(V-Sem)
Computer Engineering
Source Code:
.Net Programming
(V-Sem)
Computer Engineering
(V-Sem)
Computer Engineering
Dim s As String
s=IT IS A 3-STAR HOTEL. WE HAVE DIFFERENT TYPES OF ROOMS WITH ALL
FACILITY
Return s
Public Function reserve(By Val roomnumber As String) As Boolean
Select case roomnumber
Case room1
Return True
End Select
End Function
End Class Function
WEB APPLICATION:
.Net Programming
(V-Sem)
Computer Engineering
(V-Sem)
Computer Engineering
Next
For Each st In h.Food()
DropDownList2.Items.Remove(st)
DropDownList2.Items.Add(st)
Next
Label1.Text= h.description()
End If
ElseIf DropDownList3.SelectedIndex = 2 Then
If Not IsPostBack Then
Dim str As String
Dim st As String
For Each str In h.Room()
DropDownList1.Items.Remove(str)
DropDownList1.Items.Add(str)
Next
For Each st In h.Food()
DropDownList2.Items.Remove(st)
DropDownList2.Items.Add(st)
Next
Label1.Text= h.description()
End If
Elself DropDownList3.SelectedIndex = 2 Then
If No IsPostBack Then
Dim str1 As String
Dim st1 As String
.Net Programming
(V-Sem)
Computer Engineering
(V-Sem)
Computer Engineering
.Net Programming
(V-Sem)