VB6中如何获取记录集?
嘿伙计们,只是想问你一个简单的问题,我知道你很熟悉...我正在使用VB6,我只想从我的数据库中获取记录集。我的意思是,我有 UserID,并且使用下面提供的部分代码,它只能获取一组记录。例如,UserID 的值为 A12
,因此,UserID 为 A12
的所有记录集> 必须借助 datPayroll.Recordset.MoveNext
分别显示在文本框中。
With datPayroll
.RecordSource = "select * from tblpayroll where empid like '" & UserID & "'"
.Refresh
Me.txtRegularHours.Text = .Recordset.Fields!reghours
End With
-datPayroll:数据控制
-txtRegularHours:文本框
-UserID:变量
Hey guys, just want to ask you a simple question that I know you're familiar with... I am using VB6, I just want to get sets of records from my database. What I mean is that I have UserID and with a part of code provided below, it only gets a single set of record. Like for instance, the value of UserID is A12
, and so, all sets of records with the UserID of A12
must display in Textboxes respectively with the aid of datPayroll.Recordset.MoveNext
.
With datPayroll
.RecordSource = "select * from tblpayroll where empid like '" & UserID & "'"
.Refresh
Me.txtRegularHours.Text = .Recordset.Fields!reghours
End With
-datPayroll : DataControl
-txtRegularHours : Textbox
-UserID : Variable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想查看 MoveFirst、MoveNext 等以及 EOF
这里有一两个链接可以帮助您入门:
EOF、BOF
MoveFirst、MoveNext
您需要使用 EOF 检查 Recordset 中是否有一些数据,然后使用 MoveFirst 移动到第一条记录,并使用 MoveNext 循环。
You probably want to look at MoveFirst, MoveNext, etc. and also EOF
Here is a link or two to get you started:
EOF, BOF
MoveFirst, MoveNext
You need to check that you have some data in your Recordset using EOF, then MoveFirst to move to the first record, and loop through using MoveNext.