我找到了!只需从表中删除索引号"主键"n行数据。。
请帮我…我已经尝试过将我的数据库调用到数据网格,但现在我找不到从数据网格的选定行删除我的数据的方法
我的数据网格从这里
Private Sub cmdTampil_Click()
AdoCupu.ConnectionString = Buka
AdoCupu.RecordSource = "Select * from vJadwalRehab Where jadwalrehab between '" & Format(dtDari, "yyyy/MM/dd") & "' and '" & Format(dtpSampai, "yyyy/MM/dd") & "'"
AdoCupu.Refresh
Set dgData.DataSource = AdoCupu
End Sub
我在"删除按钮"上尝试了这些方法,但仍然无法使用
Private Sub cmdHapus_Click()
1.method 'dgData.(1).index
dgData.rows.RemoveAt (i)
'dgData.Delete
2.method ' Dim index As Integer
' index = dgData.CurrentCell.RowIndex
3.method ' delete the selected row
' dgData.rows.RemoveAt (index)
'If Not dgData.CurrentRow.IsNewRow Then
'dgData.rows.Remove (dgData.CurrentRow)
'End If
End Sub
我试过那三种方法,但都没用。。
CONN.BeginTrans
CONN.Execute "delete jadwalRehab where id='" & txtID & "'"
CONN.CommitTrans
ShowData
MsgBox "Data Jadwal Berhasil Dihapus!"
填写网格后,删除记录的简单方法是通过Adodc控件:
Private Sub cmdHapus_Click()
Dim bm As Variant
For Each bm In dgData.SelBookmarks
AdoCupu.Recordset.Bookmark = bm
AdoCupu.Recordset.Delete
Next
End Sub