Expert

                                                         login


Imports System.Data.SqlClient

Imports System.Data

Public Class WebForm1

    Inherits System.Web.UI.Page


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


    End Sub


    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim Con As New SqlConnection

        Dim Cmd As New SqlCommand

        Con.ConnectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=park;Integrated Security=True"

        Con.Open()

        Cmd = New SqlCommand("INSERT INTO park values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "')", Con)

        Cmd.ExecuteNonQuery()

        Con.Close()

        MsgBox("inserted")



    End Sub


    Protected Sub Button4_Click(sender As Object, e As EventArgs)


    End Sub

End Class

                                                        Display

Imports System.Data.SqlClient

Imports System.Data

Public Class WebForm2

    Inherits System.Web.UI.Page


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


    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim Con As New SqlConnection

        Dim Cmd As New SqlCommand

        Con.ConnectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=park;Integrated Security=True"

        Con.Open()

        Cmd.CommandText = "select * from park"

        Cmd.Connection = Con

        GridView1.DataSource = Cmd.ExecuteReader

        GridView1.DataBind()


    End Sub

End Class


                                                                       Search

Imports System.Data.SqlClient

Imports System.Data

Imports System.Data.SqlClient.SqlException


Public Class WebForm3

    Inherits System.Web.UI.Page


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


    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim Con As New SqlConnection

        Dim Cmd As New SqlCommand

        Dim Dr As SqlDataReader

        Con.ConnectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=park;Integrated Security=True"

        Con.Open()

        Cmd = New SqlCommand("select * from park where id='" + TextBox1.Text + "'", Con)

        Dr = Cmd.ExecuteReader

        If Dr.Read Then


            TextBox2.Text = Dr.GetValue(0)

            TextBox3.Text = Dr.GetValue(1)

            TextBox4.Text = Dr.GetValue(2)

            TextBox5.Text = Dr.GetValue(3)

            TextBox6.Text = Dr.GetValue(4)

            TextBox7.Text = Dr.GetValue(5)






        Else

            MsgBox("record  not found")


        End If

        Con.Close()

    End Sub


    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim Con As New SqlConnection

        Dim Cmd As New SqlCommand

        Con.ConnectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=park;Integrated Security=True"

        Cmd.Connection = Con

        Con.Open()

        Cmd.CommandText = "update park set name = '" & TextBox3.Text & "',number='" & TextBox4.Text & "', age='" & TextBox5.Text & "', gender='" & TextBox6.Text & "', email='" & TextBox7.Text & "'where id='" & TextBox1.Text & "'"

        Cmd.ExecuteNonQuery()

        MsgBox(" updated")

        TextBox1.Text = ""

        TextBox2.Text = ""

        TextBox3.Text = ""

        TextBox4.Text = ""

        TextBox5.Text = ""

        TextBox6.Text = ""

        TextBox7.Text = ""


    End Sub


    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

        Dim Con As New SqlConnection

        Dim Cmd As New SqlCommand

        Con.ConnectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=park;Integrated Security=True"

        Cmd.Connection = Con

        Con.Open()

        Cmd.CommandText = "Delete from park where id  = '" & TextBox3.Text & "'"

        Cmd.ExecuteNonQuery()

        MsgBox(" deleted")

        TextBox1.Text = ""

        TextBox2.Text = ""


    End Sub

End Class

                                                            

Comments