肚子胀屁多吃什么药好:vb中的程序,请高手详细解读一下下面程序

来源:百度文库 编辑:高校问答 时间:2024/04/23 18:08:18
为什么提示方法错误或未找到数据成员
Private Sub cmd_add_Click()
IsAdd = False
If Adodc1.Recordset.EOF = True Then
MsgBox "Good"

With Form1
Adodc1.Recordset.Fields(0) = .Text1.Text
Adodc1.Recordset.Fields(1) = .Text2.Text
Adodc1.Recordset.Fields(2) = .Text3.Text
Adodc1.Recordset.Fields(3) = .Text4.Text
Adodc1.Recordset.Fields(4) = .Text5.Text
Adodc1.Recordset.Fields(5) = .Text6.Text
Adodc1.Recordset.Fields(6) = .Text7.Text
Adodc1.Recordset.Fields(7) = .Text8.Text
Adodc1.Recordset.Fields(8) = .Text9.Text

Adodc1.Recordset.Update

End With
Else
MsgBox "Please go to end!"
End If
adoBinfoRefresh

你的代码不完整,也不清楚在哪儿卡住了,所以你可以按F8让代码逐步运行,跟踪调试。
不过我感觉你所给代码是想在数据表结尾加入一条新记录,或是更改最后一条记录.但无论如何不能是If Adodc1.Recordset.EOF = True Then;Recordset.EOF 不是一条记录,而是一个标记.如果是添加新记录,可以

rs.AddNew ([fieldlist],[valres])
如果是修改某条就移动到那一条再做处理

首先判断一下是不是在数据库的最后一个记录,如果是那会出现一个对话框,告诉你good,并且把text1到9的数据一一写入数据库.,如果不是在最后那就显示please go to end
最后一句是刷新一下

Adodc1.Recordset.Fields(1) = .Text2.Text
Text2.Text前面为什么有一个点啊?

adoBinfoRefresh
这是什么?要来干吗的,删