ADONETConnection Module With Move Operation
ADONETConnection Module With Move Operation
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;DataSource=
C:\Users\nidhidesai\Documents\Visual Studio 2010\Projects\0 ND NET
Programs\DBConnection\Student.accdb"
cn.Open()
no = 0
display()
cn.Close()
End Sub
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnUpdate.Click
Try
cn.Open()
cmd = New OleDbCommand("update Stud set
Name='"&txtName.Text&"',Sem="&txtSem.Text&"
where Rno="&txtRollNo.Text&"", cn)
cmd.ExecuteNonQuery()
MsgBox("Record Updated")
display()
Catch ex As Exception
MsgBox("Update Details")
End Try
cn.Close()
End Sub
Try
cn.Open()
cmd = New OleDbCommand("delete from Stud where Rno=" & txtRollNo.Text & "", cn)
cmd.ExecuteNonQuery()
MsgBox("Record Deleted")
display()
Catch ex As Exception
MsgBox("Delete Details")
End Try
cn.Close()
End Sub
Try
cn.Open()
cmd = New OleDbCommand("select * from Stud where Rno=" & txtRollNo.Text & "", cn)
dr = cmd.ExecuteReader()
While dr.Read()
txtName.Text = dr.Item(1)
txtSem.Text = dr.Item(2)
End While
Catch ex As Exception
MsgBox(ex.ToString, , "Record Not Found")
End Try
cn.Close()
End Sub
txtRollNo.Clear()
txtName.Clear()
txtSem.Clear()
End Sub
Me.Close()
End Sub
Sub showdata()
drow = ds.Tables(0).Rows(no)
txtRollNo.Text = drow.Item(0)
txtName.Text = drow.Item(1)
txtSem.Text = drow.Item(2)
End Sub
no = 0
showdata()
display()
End Sub
no = no – 1
If no < 0 Then
no = ds.Tables(0).Rows.Count - 1
End If
showdata()
display()
End Sub
no = no + 1
If no > ds.Tables(0).Rows.Count - 1 Then
no = 0
End If
showdata()
display()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
btnLast.Click
no = ds.Tables(0).Rows.Count - 1
showdata()
display()
End Sub
Dim i As Integer
i = DataGridView1.CurrentRow.Index
End Sub
End Class