Imports System.
Data
Imports [Link]
Public Class Form1
Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\win10\Documents\Visual
Studio 2010\Projects\datainsert\datainsert\[Link];Integrated Security=True;User Instance=True")
Dim cmd As SqlCommand
Dim ds As DataSet
Private Sub Display_Records()
Try
Dim cmd As New SqlCommand("select * from Student", con)
Dim da As New SqlDataAdapter(cmd)
ds = New DataSet
[Link](ds, "Student")
[Link] = [Link]("Student")
Catch ex As Exception
[Link]([Link])
End Try
End Sub
Private Sub ClearControls()
[Link] = ""
[Link] = ""
[Link] = ""
End Sub
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link]
Try
cmd = New SqlCommand("insert into Student values('" & CInt([Link]) & "','" & [Link] & "','" &
[Link] & "')", con)
[Link]()
[Link]()
[Link]()
MsgBox("record is inserted")
Catch ex As Exception
[Link]([Link])
End Try
End Sub
Private Sub Button2_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link]
Display_Records()
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim index As Integer = [Link]
Dim selectedRow As DataGridViewRow = [Link](index)
[Link] = [Link](0).[Link]
[Link] = [Link](1).[Link]
[Link] = [Link](2).[Link]
End Sub
Private Sub Button3_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link]
Try
Dim cmd As New SqlCommand("delete from Student where rno=@rn", con)
[Link]("@rn", [Link]).Value = CInt([Link])
[Link]()
Dim flg As Integer = [Link]
If flg > 0 Then
[Link]("Record Deleted Successfully")
ClearControls()
Display_Records()
End If
Catch ex As Exception
[Link]([Link])
Finally
[Link]()
End Try
End Sub
Private Sub Button4_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link]
Try
Dim cmd As New SqlCommand("update student set name='" & [Link] & "',course='" & [Link] & "'
where rno=" & [Link] & "", con)
[Link]()
[Link]()
[Link]()
MsgBox("Record is updated")
Catch ex As Exception
MsgBox([Link])
End Try
Display_Records()
ClearControls()
End Sub
Private Sub Button6_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link]
Try
Dim cmd As New SqlCommand("select * from student where rno='" & [Link] & "'", con)
Dim dt As New DataTable
Dim da As New SqlDataAdapter(cmd)
[Link](dt)
[Link] = dt
Catch ex As Exception
MsgBox([Link])
End Try
End Sub
End Class