VB中DataGrid1控件中新增加一条记录
ID为数据表b1的主键,我自己的代码如下:PrivateSubCommand2_Click()DataGrid1.AllowAddNew=TrueRecordset="b...
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
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 展开
1个回答
推荐于2016-06-23
展开全部
'这段代码只对图中的数据库有效
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
不懂再追问
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询