VB中如何用带码清空datagrid显示的全部数据

来源:百度知道 编辑:UC知道 时间:2024/06/12 05:42:05
我想清空DATAGRID里显示的全部数据要用什么代码呀????

‘将资料库请空或连接其他空的资料栏位便可以了。

Private Sub cmddelete_Click()
On Error GoTo errhandle
intmsg = MsgBox("Do you want to delete this records?", vbInformation + vbYesNo, "Delete")
If intmsg = vbYes Then
ADODC1.Recordset.MoveFirst
Do While Not ADODC1.Recordset.EOF
ADODC1.Recordset.Delete
ADODC1.Recordset.MoveNext
Set DataGrid1.DataSource = adotype
DataGrid1.Refresh
Loop
Else
Exit Sub
End If
Exit Sub

errhandle:
If Err.Number = 3021 Then
MsgBox "No record to delete", vbExclamation + vbOKOnly, "Error"
setbutton True
End If
End Sub