ADO.
NET Connection Module with Move Operations
Imports [Link]
'Object Linking and Embedding Database
Public Class Form1
Dim cn As New OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim adp As New OleDbDataAdapter
Dim ds As New DataSet
Dim no As Integer
Dim drow As DataRow
Public Sub display()
[Link]()
adp = New OleDbDataAdapter("select * from stud", cn)
[Link](ds)
[Link] = [Link](0)
End Sub
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As [Link]) Handles
[Link]
[Link] = "Provider=[Link].12.0;DataSource=
C:\Users\nidhidesai\Documents\Visual Studio 2010\Projects\0 ND NET
Programs\DBConnection\[Link]"
[Link]()
no = 0
display()
[Link]()
End Sub
Private Sub btnInsert_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Try
[Link]()
cmd = New OleDbCommand("insert into Stud values(" & [Link] & ",'" &
[Link] & "'," & [Link] & ") ", cn)
[Link]()
MsgBox("Record Inserted")
display()
Catch ex As Exception
MsgBox("Insert Details")
End Try
[Link]()
End Sub
Private Sub btnUpdate_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Try
[Link]()
cmd = New OleDbCommand("update Stud set
Name='"&[Link]&"',Sem="&[Link]&"
where Rno="&[Link]&"", cn)
[Link]()
MsgBox("Record Updated")
display()
Catch ex As Exception
MsgBox("Update Details")
End Try
[Link]()
End Sub
Private Sub btnDelete_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Try
[Link]()
cmd = New OleDbCommand("delete from Stud where Rno=" & [Link] & "", cn)
[Link]()
MsgBox("Record Deleted")
display()
Catch ex As Exception
MsgBox("Delete Details")
End Try
[Link]()
End Sub
Private Sub btnSearch_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Try
[Link]()
cmd = New OleDbCommand("select * from Stud where Rno=" & [Link] & "", cn)
dr = [Link]()
While [Link]()
[Link] = [Link](1)
[Link] = [Link](2)
End While
Catch ex As Exception
MsgBox([Link], , "Record Not Found")
End Try
[Link]()
End Sub
Private Sub btnClear_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link]()
[Link]()
[Link]()
End Sub
Private Sub btnClose_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link]()
End Sub
Sub showdata()
drow = [Link](0).Rows(no)
[Link] = [Link](0)
[Link] = [Link](1)
[Link] = [Link](2)
End Sub
Private Sub btnFirst_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
no = 0
showdata()
display()
End Sub
Private Sub btnPrevious_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
no = no – 1
If no < 0 Then
no = [Link](0).[Link] - 1
End If
showdata()
display()
End Sub
Private Sub btnnext_Click(ByVal sender As [Link], ByVal e As [Link]) Handles
[Link]
no = no + 1
If no > [Link](0).[Link] - 1 Then
no = 0
End If
showdata()
display()
End Sub
Private Sub btnLast_Click(ByVal sender As [Link], ByVal e As [Link]) Handles
[Link]
no = [Link](0).[Link] - 1
showdata()
display()
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim i As Integer
i = [Link]
[Link] = [Link](0, i).Value
[Link] = [Link](1, i).Value
[Link] = [Link](2, i).Value
End Sub
End Class