Dot Net Manual

download Dot Net Manual

of 20

Transcript of Dot Net Manual

  • 8/20/2019 Dot Net Manual

    1/52

     

    1

    Ex .No : 1 CHECK THE CASE OF THE CHARACTER

    Aim:

    To accept a character from console & check the case of the character.

    Procedure:

    1. Open Visual Studio .NET IDE.

    2. Choose the File-> New -> Project option to display the New Project dialog box.

    3. Give the name of the project.

    4. The New form will be displayed.

    5. Create the label, button, text boxes in the form & write coding.

    6. Save the Solution.

    7. Click Build-> Start to run the Program.

    Algorithm:

    1. 

    Enter the character in the text box.2.

      Check the Ascii value of the given character.

    3.  If the value is 65 – 90 then display it is uppercase.

    4.  If the value is 97 – 122 then display it is lowercase.

    Program:

    Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim n As Integer

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

    Button1.Click

    n = Asc(TextBox1.Text)

    Select Case n

    Case n = 65 To 90

    MsgBox("UPPER CASE")

    Case n = 97 To 122

    MsgBox("LOWER CASE")

    End Select

    End Sub

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

    Button2.Click

    End

    End Sub

    End Class 

  • 8/20/2019 Dot Net Manual

    2/52

     

    2

    Sample Output:

    Result:

    Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    3/52

     

    3

    Ex. No: 2 CHECK THE GIVEN CHARACTER IS VOWEL OR NOT

    Aim:

    To Write a program to accept a character from console & display whether it is vowel or

    not.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the label, button, text boxes in the form & write coding.

    6.  Save the Solution. Click Build-> Start to run the Program

    Algorithm:

    1.  Enter the character in the textbox.

    2. 

    Check the character whether it is vowel or not.

    3.  If it is vowel display, the character is vowel.

    4.  Otherwise display the character is not vowel.

    Program:

    Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim s As Char

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

    Button1.Click

    s = TextBox1.Text

    Select Case s

    Case "a", "e", "i", "o", "u"

    MsgBox("VOWEL")

    Case "A", "E", "I", "O", "U"

    MsgBox("VOWEL")

    Case Else

    MsgBox("NOT VOWEL")

    End Select

    End Sub

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

    Button2.Click

    End

    End Sub

    End Class 

  • 8/20/2019 Dot Net Manual

    4/52

     

    4

    Sample Output: 

    Result:

    Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    5/52

     

    5

    Ex. No: 3 CONVERT THE CASE OF THE CHARACTER

    Aim:

    To write a VB.NET program to accept a character from console & convert the case of the

    character.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the label, button, text boxes in the form & write coding.

    6.  Save the Solution.

    7.  Click Build-> Start to run the Program. 

    Algorithm:

    1.  Enter the string in the text box.

    2.  Use the functions to convert to lowercase or uppercase.

    3.  If the given string is uppercase convert to lowercase.

    4.  If the given string is lowercase convert to uppercase.

    Program:

    Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim n As Integer

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

    Handles Button1.Click

    TextBox2.Text = LCase(TextBox1.Text)

    End Sub

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

    Handles Button2.Click

    TextBox2.Text = UCase(TextBox1.Text)

    End SubPrivate Sub end_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 

    Button3.Click

    End

    End Sub

    End Class

  • 8/20/2019 Dot Net Manual

    6/52

     

    6

    Sample Output:

  • 8/20/2019 Dot Net Manual

    7/52

     

    7

    Output: 

    Result:

    Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    8/52

     

    8

    Ex. No: 4 IMPLEMENT A MENU BASED TEXT EDITOR WITH PASTE, COPY OPERATION

    Aim:

    To write a menu based VB.NET program to implement a text editor with cut, copy,

    paste, save, close operations.

    Procedure:

    1. Open Visual Studio .NET IDE.

    2. Choose the File-> New -> Project option to display the New Project dialog box.

    3. Give the name of the project.

    4. The New form will be displayed.

    5. Create the menu, rich text box in the form & write coding.

    6. Save the Solution.

    7.  Click Build-> Start to run the Program.

    Algorithm:

    1. Create the menu editor in the form.

    2. Enter the text in the rich text box.

    3. Save menu - Save the text in any filename.

    4. Open menu - load the file in rich text box.

    5. Cut menu  – select the text & clear the space

    6. Copy menu - copy the selected text.

    7. Paste menu – paste the selected text in requested place.

    Program:

    Public Class Form1Inherits System.Windows.Forms.FormDim s As String

    Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click

    RichTextBox1.SaveFile("d:\notepad.txt")End Sub

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

    System.EventArgs) Handles MenuItem7.ClickEndEnd Sub

    Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menuitem3.Clicks = RichTextBox1.SelectedTextRichTextBox1.SelectedText = ""End Sub

    Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menuitem4.Clicks = RichTextBox1.SelectedText

    End Sub

    Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menuitem5.ClickRichTextBox1.SelectedText = s

  • 8/20/2019 Dot Net Manual

    9/52

     

    9

    End Sub

    Private Sub MenuItem3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menuitem3.Click

    RichTextBox1.LoadFile("d:\notepad.txt")End Sub

    End Class 

    Sample Output:

  • 8/20/2019 Dot Net Manual

    10/52

     

    10

    Output: 

    Result:Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    11/52

     

    11

    Ex. No: 5 TO IMPELEMENT A CALCULATOR

    Aim:

    To write a program to implement a calculator with memory & recall operations.

    Procedure:

    1. Open Visual Studio .NET IDE.

    2. Choose the File-> New -> Project option to display the New Project dialog box.

    3. Give the name of the project.

    4. The New form will be displayed.

    5. Create the label, button, text boxes in the form & write coding.

    6. Save the Solution.

    7. Click Build-> Start to run the Program.

    8. Click the add button to add the values, & Click the subtract button to subtract

    Values etc. 

    Algorithm:

    1. Enter the values in the textbox1 & textbox2.

    2. Add the textbox1 & textbox2 values & place the result in the textbox3.

    3. Do the same way for subtract, multiply & divide.

    Program:

    Public Class Form1Dim a, m As Integer

    Dim op As Char

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.ClickTextBox1.Text = m

    End Sub

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

    TextBox1.Clear()End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.ClickTextBox1.AppendText("1")End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.ClickTextBox1.AppendText("2")End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.ClickTextBox1.AppendText("3")

    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

  • 8/20/2019 Dot Net Manual

    12/52

     

    12

    TextBox1.AppendText("4")End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

    TextBox1.AppendText("5")End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.ClickTextBox1.AppendText("6")End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.ClickTextBox1.AppendText("7")End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.ClickTextBox1.AppendText("8")End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.ClickTextBox1.AppendText("9")End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.ClickTextBox1.AppendText("0")

    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click

    a = Val(TextBox1.Text)op = "+"TextBox1.Clear()

    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click

    a = Val(TextBox1.Text)op = "-"TextBox1.Clear()

    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click

    a = Val(TextBox1.Text)op = "*"TextBox1.Clear()

    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click

    a = Val(TextBox1.Text)op = "/"TextBox1.Clear()

    End Sub

  • 8/20/2019 Dot Net Manual

    13/52

     

    13

    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click

    Select Case opCase "+"

    TextBox1.Text = a + Val(TextBox1.Text)Case "-"

    TextBox1.Text = a - Val(TextBox1.Text)

    Case "*"TextBox1.Text = a * Val(TextBox1.Text)

    Case "/"TextBox1.Text = a / Val(TextBox1.Text)

    End SelectEnd Sub

    End Class 

    Sample Output: 

    Output: 

    Result:

    Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    14/52

     

    14

    Ex. No: 6 TO PICK A DATE FORM CALENDAR & DISPLAY THE DAY, MONTH & YEAR

    Aim:

    To write a program to pick a date from a calendar control & display the day, month,

    year details in separate boxes.

    Procedure:

    1. Open Visual Studio .NET IDE.

    2. Choose the File-> New -> Project option to display the New Project dialog box.

    3. Give the name of the project.

    4. The New form will be displayed.

    5. 

    Create the datetimepicker control label, text boxes in the form & write coding.6. Save the Solution.

    7. Click Build-> Start to run the Program.

    Algorithm:

    1.  Click any values in date time picker control.

    2.  It will display the day, month & year in appropriate textboxes.

    Program:

    Public Class Form1Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    TextBox1.Text = DateTimePicker1.Value.DayTextBox2.Text = DateTimePicker1.Value.MonthTextBox3.Text = DateTimePicker1.Value.Year

    End SubEnd Class

  • 8/20/2019 Dot Net Manual

    15/52

     

    15

    Sample Output: 

    Result:

    Thus the program is prepared & verified. 

  • 8/20/2019 Dot Net Manual

    16/52

     

    16

    7. PERFORM TIMER BASED QUIZ QUESTION

    Aim:

    To Write a VB.Net Program to perform timer based quiz question.

    Procedure:1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the Labels, Buttons, and Radiobuttons in the form & write coding.

    6.  Save the Solution.

    7.  Click Build-> Start to run the Program.

    Algorithm:

    1.  Create the 5 Labels, 3 Buttons, 10 Radio buttons, 5 Group box in the form.

    2.  Type Questions in Labels.

    3.  Adding two Radio buttons each Group box.

    4.  Adding Timer Controls set interval as 15000.

    5.  Write the coding.

    6.  Click Start Button, Time is starting.

    7.  Click the Radio Buttons to correct Answer.

    8. 

    Mark is Greater than 3, Message is displayed Pass.

    Program:

    Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim n As Integer

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

    Handles Button1.Click

    Button2.Show()

    Button1.Hide()

    Button3.Show()

    End Sub

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

    Handles MyBase.Load

    Button2.Hide()

  • 8/20/2019 Dot Net Manual

    17/52

     

    17

    Button3.Hide()

    End Sub

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

    Button3.Click

    End

    End Sub

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

    Handles Button2.Click

    If RadioButton1.Checked = True Then

    n = 1

    End If

    If RadioButton4.Checked = True Then

    n = n + 1

    End If

    If RadioButton5.Checked = True Then

    n = n + 1

    End If

    If RadioButton8.Checked = True Then

    n = n + 1

    End If

    If RadioButton10.Checked = True Then

  • 8/20/2019 Dot Net Manual

    18/52

     

    18

    n = n + 1

    End If

    If n >= 3 Then

    MsgBox("Pass")

    Else

    MsgBox("Fail")

    End If

    End Sub

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

    Timer1.Tick

    Timer1.Start()

    If RadioButton1.Checked = True Then

    n = 1

    End If

    If RadioButton4.Checked = True Then

    n = n + 1

    End If

  • 8/20/2019 Dot Net Manual

    19/52

     

    19

    If RadioButton5.Checked = True Then

    n = n + 1

    End If

    If RadioButton8.Checked = True Then

    n = n + 1

    End If

    If RadioButton10.Checked = True Then

    n = n + 1

    End If

    If Timer1.Interval = 15000 Then

    MsgBox("Time is Elapsed")

    If n >= 3 Then

    MsgBox("Pass")

    Else

    MsgBox("Fail")

    End If

    End

    End If

    End Sub

    End Class

    Result:

    Thus the program is prepared and verified.

  • 8/20/2019 Dot Net Manual

    20/52

     

    20

    8. TO IMPELEMENT A COMMON DIALOG BOX

    Aim:

    To write a program to implement File, Directory and Directory Controls in a common dialog

    box.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the MainMenu,OpenFileMenu,SaveFileMenu,FontDialog,ColorDialog in the form

    & write coding.

    6.  Save the Solution.

    7.  Click Build-> Start to run the Program.

    Algorithm:

    1.  Click the File Menu .

    2.  Click open, text file is open.

    3.  Click save, the file is saved.

    4.  Click SelectedFont, Font style is changed.

    5.  Click SelectedColor, FontColor is changed.

    .

    Program:Imports System.IO

    Imports System.IO.StreamWriter

    Public Class Form1

    Inherits System.Windows.Forms.Form

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

    Handles MenuItem4.ClickTry

    With FontDialog1

    .Font = RichTextBox1.Font

    .Color = RichTextBox1.ForeColor

    If .ShowDialog = DialogResult.OK Then

    setFont()

    End If

  • 8/20/2019 Dot Net Manual

    21/52

     

    21

    End With

    Catch es As Exception

    MessageBox.Show(es.Message)

    End Try

    End Sub

    Private Sub setFont()

    Try

    With FontDialog1

    RichTextBox1.Font = .Font

    If .ShowColor Then

    RichTextBox1.ForeColor = .Color

    End If

    End With

    Catch ex As Exception

    MessageBox.Show(ex.Message)

    End TryEnd Sub

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

    Handles Button1.Click

    RichTextBox1.Text = " "

    End Sub

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

    Handles MenuItem2.Click

  • 8/20/2019 Dot Net Manual

    22/52

     

    22

    Dim FileName As String

    Dim sr As System.IO.StreamReader

    Try

    With OpenFileDialog1

    .Filter = "Text files (*.txt)|*.txt|" & "All files|*.*"

    If .ShowDialog() = DialogResult.OK Then

    FileName = .FileName

    sr = New System.IO.StreamReader(.OpenFile)

    RichTextBox1.Text = sr.ReadToEnd()

    End If

    End With

    Catch es As Exception

    MessageBox.Show(es.Message)

    Finally

    If Not (sr Is Nothing) Then

    sr.Close()

    End If

    End Try

    End Sub

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

    Handles MenuItem3.Click

    Dim FileName As String

    Dim sw As System.IO.StreamWriter

    Try

    With SaveFileDialog1

    .FileName = FileName

    .Filter = "Text files (*.txt)|*.txt|" & "All files|*.*"If .ShowDialog() = DialogResult.OK Then

    FileName = .FileName

  • 8/20/2019 Dot Net Manual

    23/52

     

    23

    FileName = .FileName

    sw = New System.IO.StreamWriter("FileName")

    sw.Write(RichTextBox1.Text)

    End If

    End With

    Catch es As Exception

    MessageBox.Show(es.Message)

    Finally

    If Not (sw Is Nothing) Then

    sw.Close()

    End If

    End Try

    End Sub

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

    Handles MenuItem5.Click

    Static CustomColors() As Integer = {RGB(255, 0, 0), RGB(0, 255, 0), RGB(0, 0, 255)}

    Try

    With ColorDialog1

    .Color = RichTextBox1.ForeColor

    .CustomColors = CustomColors

    If .ShowDialog() = DialogResult.OK Then

    RichTextBox1.ForeColor = .Color

    CustomColors = .CustomColors

    End If

    ColorDialog1.Reset()

    End With

    Catch es As Exception

    MessageBox.Show(es.Message)

    End Try

    End Sub

    End Class

    Result:Thus the program is prepared and verified.

  • 8/20/2019 Dot Net Manual

    24/52

     

    24

    9. TO STORE THE DETAILS OF STUDENTS USING ADO.NET

    Aim:

    To develop a database application using ADO.NET to store the details of students.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the label, button, text boxes in the form & write coding.

    6.  Save the Solution.

    7.  Click Build-> Start to run the Program 

    8. 

    Create database & Table in the SQL server & store the student details through theform.

    Algorithm:

    1.  To store the student details using insert command .

    2.  Execute the insert command.

    3.  Now the data will be stored in the table.

    Program:Imports System.Data.SqlClient

    Public Class Form1

    Inherits System.Windows.Forms.Form

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

    Handles Button2.Click

    End

    End Sub

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

    store.Click

    Dim cnn As New SqlConnection

    Dim str As String

    Dim cmd As New SqlCommand

  • 8/20/2019 Dot Net Manual

    25/52

     

    25

    tr = "user id=sa;Data Source = CC2-52;;Initial Catalog = master;Integrated Security=SSPI"

    cnn = New SqlConnection(str)

    Dim rows As Integer

    Dim cmdinsert As SqlCommand

    cmdinsert = New System.Data.SqlClient.SqlCommand("insert into studs(num,nam,dept)

    values('" & Val(id_txt.Text) & "','" & name_txt.Text & " ',' " & dept.Text & " ')")

    MsgBox("ok")

    cmdinsert.Connection = cnn

    cnn.Open()

    cmdinsert.ExecuteNonQuery()MsgBox("Record is Inserted")

    cnn.Close()

    End Sub

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

    Handles MyBase.Load

    End SubEnd Class

  • 8/20/2019 Dot Net Manual

    26/52

     

    26

    Result:

    Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    27/52

     

    27

    10. TO INSERT, UPDATE & DELETE THE DETAILS OF STUDENTS USING ADO.NET

    Aim:

    To develop a database application using ADO.NET to insert, update & delete operations.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the label, button, text boxes in the form & write coding.

    6.  Save the Solution.

    7.  Click Build-> Start to run the Program 

    8.  Create database & Table in the SQL server & insert, update & delete the student details

    through the form.

    Algorithm:

    1.  To add the student details using insert command .

    2.  Execute the insert command.

    3.  Now the data will be stored in the table.

    4.  Using update command we can update the datas.

    5. 

    Using delete command we can delete the records.

    Program:

    Imports System.Data.SqlClient

    Public Class Form1

    Inherits System.Windows.Forms.Form

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

    System.EventArgs) Handles insert_button.Click

    Dim cnn As New SqlConnection

    Dim str As String

    Dim cmd As New SqlCommand

  • 8/20/2019 Dot Net Manual

    28/52

     

    28

    str = "user id=sa;Data Source = CC2-52;;Initial Catalog = master;Integrated Security=SSPI"

    cnn = New SqlConnection(str)

    Dim rows As Integer

    Dim cmdinsert As SqlCommand

    cmdinsert = New System.Data.SqlClient.SqlCommand("insert into studs(num,nam,dept)

    values('" & Val(id_txt.Text) & "','" & name_txt.Text & " ',' " & dept.Text & " ')")

    MsgBox("ok")cmdinsert.Connection = cnn

    cnn.Open()

    cmdinsert.ExecuteNonQuery()

    MsgBox("Record is Inserted")

    cnn.Close()

    End Sub

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

    System.EventArgs) Handles update_button.ClickDim cnn As New SqlConnection

    Dim str As String

    Dim cmd As New SqlCommand

    str = "user id=sa;Data Source = CC2-52;;Initial Catalog = master;Integrated Security=SSPI"

    cnn = New SqlConnection(str)

    Dim rows As Integer

    Dim cmdupdate As SqlCommand

    cmdupdate = New System.Data.SqlClient.SqlCommand("update studs set nam='" &

    name_txt.Text & " ',dept=' " & dept.Text & " ' where num ='" & Val(id_txt.Text) & "'")

    MsgBox("ok")

    cmdupdate.Connection = cnn

  • 8/20/2019 Dot Net Manual

    29/52

     

    29

    cnn.Open()

    cmdupdate.ExecuteNonQuery()

    MsgBox("Record is updated")

    cnn.Close()

    End Sub

    Private Sub del_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles del_Button.Click

    Dim cnn As New SqlConnection

    Dim str As String

    Dim cmd As New SqlCommand

    str = "user id=sa;Data Source = CC2-52;;Initial Catalog = master;Integrated Security=SSPI"

    cnn = New SqlConnection(str)

  • 8/20/2019 Dot Net Manual

    30/52

     

    30

    Dim rows As Integer

    Dim cmddelete As SqlCommand

    cmddelete = New System.Data.SqlClient.SqlCommand("delete from studs where num='"

    & Val(id_txt.Text) & "'")

    MsgBox("ok")

    cmddelete.Connection = cnn

    cnn.Open()

    cmddelete.ExecuteNonQuery()

    MsgBox("Record is deleted")

    cnn.Close()

    End Sub

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

    Handles end_button.Click

    End

    End Sub

    End Class

    Result: Thus the program is prepared & verified. 

  • 8/20/2019 Dot Net Manual

    31/52

     

    31

    11. TO DISPLAY RECORDS USING DATAGRID

    Aim:

    To develop a database application using dagtagrid to display records.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the data grid in the form & write coding.

    6.  Save the Solution.

    7.  Click Build-> Start to run the Program 

    8.  Create database & Table in the SQL server. 

    Algorithm:

    1.  Click serverExplorer & right click Dataconnections .

    2.  In servers selcct the suboption sql servers.

    3.  Expand the option & click master.

    4.  From their select the table name studs.

    5.  Drag the table & fix it in the datagrid.

    6.  In sqlconnection select provider name, &Data source name.

    7.  Connect datasouce in the properties window.

    8. 

    In sql Data adapter right click & config it.

    9.  The data set is created.

    Program:

    Imports System.Data.SqlClient

    Public Class Form1

    Inherits System.Windows.Forms.Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load

    SqlDataAdapter1.Fill(DataSet11.stu1)

    End Sub End Class

    Result: Thus the program is prepared & verified

  • 8/20/2019 Dot Net Manual

    32/52

     

    32

  • 8/20/2019 Dot Net Manual

    33/52

     

    33

    12. TO ADD , EDIT & MODIFY RECORDS USING DATAGRID

    Aim:

    To develop a database application using dagtagrid to add , edit & modify records.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the datagrid in the form & write coding.

    6.  Save the Solution.

    7.  Click Build-> Start to run the Program 

    8.  Create database & Table in the SQL server. 

    Algorithm:

    1.  Click serverExplorer & right click Dataconnections .

    2.  In servers selcct the suboption sql servers.

    3.  Expand the option & click master.

    4.  From their select the table name studs.

    5.  Drag the table & fix it in the datagrid.

    6.  In sqlconnection select provider name, &Data source name.

    7. 

    Connect datasouce in the properties window.

    8.  In sql Data adapter right click & config it.

    9.  The data set is created.

    Program:

    Imports System.Data.SqlClient

    Imports System.Windows.Forms

    Imports System.EventArgs

    Public Class Form1

    Inherits System.Windows.Forms.Form

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

    Handles MyBase.Load

    SqlDataAdapter1.Fill(DataSet11.stu1)

    End Sub

  • 8/20/2019 Dot Net Manual

    34/52

     

    34

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

    Handles Button1.Click

    Dim con As New SqlClient.SqlConnection

    Dim com As New SqlCommand

    Dim adap As New SqlDataAdapter

    Dim ds As New DataSet

    con = New SqlConnection("user id=sa;Data Source = CC2-52;;Initial Catalog =

    master;Integrated Security=SSPI")

    con.Open()

    'com.CommandText = "delete from stu1 where stud_id='datagrid1.currentcell()'"

    com.CommandText = "delete from stu1 "

    com.Connection = con

    com.ExecuteNonQuery()

    adap = New SqlDataAdapter("select * from stu1", con)

    adap.Fill(ds, "1")

    DataGrid1.DataSource = ds.Tables("1")

    End Sub

    Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As

    System.Windows.Forms.NavigateEventArgs) Handles DataGrid1.Navigate

    Dim con As New SqlConnection

    Dim com As New SqlCommand

    Dim ds As New DataSet

    Dim adap As New SqlDataAdapter

    con = New SqlConnection("user id=sa;Data Source = CC2-52;;Initial Catalog =

    master;Integrated Security=SSPI")

    con.Open()

    com.CommandText = "update stu1 set stud_dept='" & DataGrid1.CurrentCell() &

    "',stud_name='" & DataGrid1.CurrentCell() & "' where stud_id='" & DataGrid.CurrentCell() & "'"

    com.Connection = con

    com.ExecuteNonQuery()

    adap = New SqlDataAdapter("select * from stu1", con)

    adap.Fill(ds, "1")

    DataGrid1.DataSource = ds.Tables("1")

    End Sub

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

    Handles Button2.Click

    Dim con As New SqlClient.SqlConnection

    Dim com As New SqlCommand

    Dim adap As New SqlDataAdapter

    Dim ds As New DataSet

    con = New SqlConnection("user id=sa;Data Source = CC2-52;;Initial Catalog =

    master;Integrated Security=SSPI")

    con.Open()

  • 8/20/2019 Dot Net Manual

    35/52

     

    35

    com.CommandText = "insert into stu1 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" +

    TextBox3.Text + "')"

    com.Connection = con

  • 8/20/2019 Dot Net Manual

    36/52

     

    36

    com.ExecuteNonQuery()

    adap = New SqlDataAdapter("select * from stu1", con)

    adap.Fill(ds, "1")

    DataGrid1.DataSource = ds.Tables("1")

    End Sub

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

    Handles Button3.Click

    TextBox1.Text = ""

    TextBox2.Text = ""

    TextBox3.Text = ""

    End Sub

    End Class

    Result: Thus the program is prepared & verified. 

  • 8/20/2019 Dot Net Manual

    37/52

     

    37

  • 8/20/2019 Dot Net Manual

    38/52

     

    38

    13. TO CHANGE CASE CONVERSION

    Aim:

    To Create a Simple ASP.NET page to output text with a form, two html text boxes, anhtml button ,and an html element..

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Select ASP.Net webapplication,Give the name of the project.

    4.  The New asp.net form will be displayed.

    5.  Create the Labels,Buttons,Text boxes n the form & write coding.

    6.  Save the Solution.

    7. 

    Click Debug-> Start to run the Program 

    Algorithm:

    1.  Create The ASP.Net form and write span details in html form.

    2.  Execute ASP.Net form.

    3.  Give Lower String in Textbox1

    4.  Click the Button

    5. 

    String is Converted into Uppercase

    Program:

    Html Coding

    Uppercase String

    ASP.NET Coding

    Public Class WebForm1

    Inherits System.Web.UI.Page

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

    Handles Button1.Click

    TextBox2.Text = UCase(TextBox1.Text)

    End Sub

    End Class

    Result: Thus the program is prepared & verified. 

  • 8/20/2019 Dot Net Manual

    39/52

     

    39

  • 8/20/2019 Dot Net Manual

    40/52

     

    40

    14. CREATING A WEB CONTROLS

    Aim:

    To create a web controls to a page with three different controls to the ASP.NET page

    for a reserving rooms in Hotel.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Select ASP.Net webapplication; Give the name of the project.

    4.  The New asp.net form will be displayed.

    5.  Solution Explorer -> right click ->Add -> Add New Item.

    6.  Click WebUserControl and save form.

    7.  Create the Labels, Buttons, DropDown List Control n the form & write coding.

    8.  Save the Solution.

    9. 

    Click Build ->Select Build Solution. 

    Algorithm:

    1.  Create The ASP.Net form and Drag Webusercontrols in to form.

    2.  Execute ASP.Net form.

    3.  Select Room Type and Click Enter Button

    4.  Display the room rent.

    Program:

    WebUserControl Coding:

    Room

    Amount         

  • 8/20/2019 Dot Net Manual

    41/52

     

    41

    RoomType     

    Single

    Double

    AC

             &

    nbsp; 

    Hotel

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

    Handles Button1.Click

    Label2.Text = "Room Rent is :" + DropDownList1.SelectedItem.Value

  • 8/20/2019 Dot Net Manual

    42/52

     

    42

    End Sub

    Result: Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    43/52

     

    43

    15. DISPLAY THE RECORD IN REPEATER CONTROL

    Aim:

    To create application for accessing a SQL database by using ADO.Net by connectingto the SQL Server database and call a stored procedure.You then display the data in a Repeater

    control.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Select ASP.Net web application; Give the name of the project.

    4.  The New asp.net form will be displayed.

    5.  Solution Explorer -> right click ->Add -> Add New Item.

    6. 

    Click Repeater and Place to form.

    7.  Click HTML page and write coding .

    8.  Save the Solution.

    9.  Click Build ->Select Build Solution. 

    Algorithm:

    1.  Create The ASP.Net form and connect to sql database in form.

    2.  Execute ASP.Net form.

    3. 

    Display the student details.

    Program:

    HTML CODING:

    WebForm1

  • 8/20/2019 Dot Net Manual

    44/52

     

    44

     

     

               &nb

    sp;

    Displaying

    Student Details

    Number

  • 8/20/2019 Dot Net Manual

    45/52

     

    45

    Name

    department

    Title

  • 8/20/2019 Dot Net Manual

    46/52

     

    46

    CODING:

    Imports System.Data.SqlClient

    Public Class WebForm1

    Inherits System.Web.UI.Page

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

    Dim cn As New SqlConnection("Data Source=CC2-52;database=master;Integrated

    Security=SSPI")

    cn.Open()

    Dim cmd As New SqlCommand("sp1", cn)

    Dim ds As New DataSet

    cmd.CommandType = CommandType.StoredProcedure

    Dim da = New SqlDataAdapter(cmd)

    da.Fill(ds)TitleRepeater.DataSource = ds

    TitleRepeater.DataBind()

    cn.Close()

    End Sub

    Result: Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    47/52

     

    47

  • 8/20/2019 Dot Net Manual

    48/52

     

    48

    16. HOTEL MANAGEMENT SYSTEM USING WEBSERVICES

    Aim:

    To create a web services application for calling a Web service for a hotel named full,

    and you call another web service for for a hotel named empty, and retrieve information

    regarding room availability..

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Select ASP.Net web Service application; Give the name of the project.

    4.  The New asp.net web service form will be displayed. Name as Hotel.

    5.  Click Code View and write coding.

    6.  Save the Solution.

    7.  Click Build ->Select Build Solution. 

    Algorithm:

    1.  Create The ASP.Net web service form.

    2.  Execute ASP.Net form.

    3.  Click Reserve. It is display reservation details.

    4.  Click Price.It is display the price of room.

    5.  Click Description. It is display the hotel description.

    6. 

    Click Room. It is display the room details7.  Click Food. It is display foods available in hotel.

    8.  End of the program

    Program:

    Imports System.Web.Services

    _

    Public Class Service1

    Inherits System.Web.Services.WebService

    _

    Public Function Reserve(ByVal strRoomType1 As String, ByVal strRoomType2 As String, ByVal

    dtmStratDate As Date, ByVal dtmEndDate As Date) As Boolean

    Dim r1 As String

    Dim r2 As String

    End Function

  • 8/20/2019 Dot Net Manual

    49/52

     

    49

  • 8/20/2019 Dot Net Manual

    50/52

     

    50

    Dim sd As Date

    Dim ed As Date

    Dim res As Boolean

    Return r1 = strRoomType1

    Return r2 = strRoomType2

    Return sd = dtmStratDate

    Return ed = dtmEndDate

    _

    Public Function Price(ByVal RoomType As String) As Double

    Dim a As Double

    a = RoomType

    Select Case a

    Case 1

    Return 1000

    Case 2

    Return 2000

    Case 3

    Return 3000

    Case 4

    Return 4000

    Case 5

    Return 10000

    End Select

    End Function

    _

    Public Function Description() As String

    Return "FRIENDS HOTEL,167,MahatmaGandi Street,Anna Salai,Chennai-01.Ph:23456789"

    End Function

    _

    Public Function Room() As String

    Return "1.Single Room 2.Double Room 3.Single AC Room 4.Double AC Room 5.Hall"

    End Function

    _Public Function Food() As String

    Return "1.Idly 2.Dosai 3.Poori 4.Barotta 5.Pongal"

    End Function

    End Class

    Result: Thus the program is prepared & verified.

  • 8/20/2019 Dot Net Manual

    51/52

     

    51

  • 8/20/2019 Dot Net Manual

    52/52

     

    17. CHECK THE NUMBER IS PRIME

    Aim:

    To accept a number from console & check number is prime or not.

    Procedure:

    1.  Open Visual Studio .NET IDE.

    2.  Choose the File-> New -> Project option to display the New Project dialog box.

    3.  Give the name of the project.

    4.  The New form will be displayed.

    5.  Create the label, button, text boxes in the form & write coding.

    6.  Save the Solution.

    7.  Click Build-> Start to run the Program.

    Algorithm:

    1.  Enter the number in the text box.

    2.  Click check button.

    3.  Display the number is prime or not.

    Program:Public Class Form1

    Inherits System.Windows.Forms.Form

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

    Handles Button1.Click

    Dim n As Integer

    Dim p As Integer

    n = Val(TextBox1.Text)

    p = n % 2

    If p = 0 Then

    MsgBox("Prime Number")

    Else

    MsgBox("Not Prime Number")

    End If

    End Sub

    End Class