VB中DataGrid1控件中新增加一条记录

ID为数据表b1的主键,

我自己的代码如下:

Private Sub Command2_Click()
DataGrid1.AllowAddNew = True

Recordset = "b1"
With Adodc1
Adodc1.RecordSource = "insert into b1 values('Text1.Text','Text2.Text','Text3.Text')"

End With
Adodc1.Recordset.AddNew
Adodc1.Recordset.Update

End Sub

'这段代码只对图中的数据库有效
Private Sub Command2_Click()
DataGrid1.AllowAddNew = True


Adodc1.RecordSource = "select * from b1"
With Adodc1.Recordset
    .AddNew
    .Fields(1) = Text1
    .Fields(2) = Text2
    .Fields(3) = Text3

    .Update
End With

End Sub

不懂再追问

温馨提示:答案为网友推荐,仅供参考
相似回答