我要向一数据表中插入数据,数据表的个字段名分别是:dutyID,dutyname,introduction,能插入成功。虽然数据插入到最后一行,但是插入数据后,第一条记录却不见了!不知小弟说明白没有,反正是这个情况。哪位大侠能帮帮小弟啊!
程序源代码如下:
Dim jinggao As Integer
Dim success As Integer
If Text1.Text = "" And Text2.Text = "" Then
jinggao = MsgBox("填写数据不完整!")
Adodc1.Recordset.Open
Else: If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveLast
Adodc1.Recordset.Fields("dutyID") = Text1.Text
Adodc1.Recordset.Fields("dutyname") = Text2.Text
Adodc1.Recordset.Fields("introduction") = Text3.Text
Adodc1.Recordset.AddNew
Adodc1.Refresh
Adodc1.Recordset.Close
success = MsgBox("插入数据成功!")(数据表第三个字段:introduction 可以为空)。
程序源代码如下:
Dim jinggao As Integer
Dim success As Integer
If Text1.Text = "" And Text2.Text = "" Then
jinggao = MsgBox("填写数据不完整!")
Adodc1.Recordset.Open
Else: If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveLast
Adodc1.Recordset.Fields("dutyID") = Text1.Text
Adodc1.Recordset.Fields("dutyname") = Text2.Text
Adodc1.Recordset.Fields("introduction") = Text3.Text
Adodc1.Recordset.AddNew
Adodc1.Refresh
Adodc1.Recordset.Close
success = MsgBox("插入数据成功!")(数据表第三个字段:introduction 可以为空)。
你的代码逻辑有问题~~~ Dim jinggao As Integer
Dim success As Integer
If Text1.Text = "" And Text2.Text = "" Then
jinggao = MsgBox("填写数据不完整!")
exit sub
end if
Adodc1.Recordset.Open
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("dutyID") = Text1.Text
Adodc1.Recordset.Fields("dutyname") = Text2.Text
Adodc1.Recordset.Fields("introduction") = Text3.Text
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.Recordset.Close
success = MsgBox("插入数据成功!")