读书人

用adodoc控件 ,movenext后 ,为何值不变

发布时间: 2013-03-21 10:08:17 作者: rapoo

用adodoc控件 ,movenext后 ,为什么值不变呢???

Private Sub Command1_Click()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\db.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "Select * From aaa where id=1"

Adodc1.Refresh

Text1.Text = Adodc1.Recordset.Fields("name").Value

End Sub

Private Sub Command2_Click()
Adodc1.Recordset.MoveNext
Adodc1.Refresh
Text1.Text = Adodc1.Recordset.Fields("name").Value
End Sub




怎么点击Command2后,text1.text的值,怎么不变啊??不是把指针向下移动了吗

[解决办法]
去掉command2中的adodc1.refresh

[解决办法]
movenext后不用再刷新
[解决办法]
你的第二个问
For i = 0 To Adodc1.Recordset.Fields.Count - 1
If Adodc1.Recordset.Fields(i).Name = "name" Then

MsgBox Adodc1.Recordset.Fields(i + 1).Name
End If
Next

读书人网 >VB

热点推荐