この削除ボタンを機能させるにはどうすればよいですか?Public Class Form1 Dim inc As Integer Dim MaxRows As Integer Dim dbProvider As String Dim dbSource As String Dim con As New OleDb.OleDbConnection Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String
Private Sub GroupBox1_Enter(sender As System.Object, e As System.EventArgs) Handles GroupBox1.Enter
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = C:Desktop\AddressBook\AddressBook.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT * From Master_Details"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Master_Details")
MaxRows = ds.Tables("Master_Details").Rows.Count
inc = -1
MsgBox("Database is now open")
con.Close()
MsgBox("Database is now closed")
txtcode.Text = ds.Tables("Master_Details").Rows(0).Item(0)
txtdprt.Text = ds.Tables("Master_Details").Rows(0).Item(1)
txtgroup.Text = ds.Tables("Master_Details").Rows(0).Item(2)
txtepf.Text = ds.Tables("Master_Details").Rows(0).Item(3)
txtdesignation.Text = ds.Tables("Master_Details").Rows(0).Item(4)
txtename.Text = ds.Tables("Master_Details").Rows(0).Item(5)
txtjdate.Text = ds.Tables("Master_Details").Rows(0).Item(6)
txtdob.Text = ds.Tables("Master_Details").Rows(0).Item(7)
txtnicn.Text = ds.Tables("Master_Details").Rows(0).Item(8)
txtgender.Text = ds.Tables("Master_Details").Rows(0).Item(9)
txttcodes.Text = ds.Tables("Master_Details").Rows(0).Item(10)
Return
End Sub
Private Sub btndelete_Click(sender As System.Object, e As System.EventArgs) Handles btndelete.Click
If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No
MsgBox("Operation Cancelled")
Exit Sub
End If
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("Master_Details").Rows(ds.Tables("Master_Details").Rows.Count).Delete()
MaxRows = MaxRows - 1
inc = 0
da.Update(ds, "Master_Details")
NavigateRecords()
End Sub