通过dataGrid直接添加删除纪录
Dim a As Boolean
Dim b As Boolean
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = strCon
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSql
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Command1_Click()
On Error Resume Next
Adodc1.Recordset.Update
DataGrid1.Row = DataGrid1.Row + 1
End Sub
Private Sub Command2_Click()
On Error Resume Next
Adodc1.Recordset.delete
End Sub
Private Sub DataGrid1_Error(ByVal DataError As Integer, Response As Integer)
MsgBox "字符长度不能大于定义长度!"
Response = 0
If b = True Then
b = False
a = True
End If
End Sub
Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1_Click
DataGrid1.SetFocus
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
b = True
DataGrid1.SetFocus
If a = True Then
Cancel = True
b = False
a = False
End If
End Sub