vb.net实例代码 在访问表中遍历记录

发布时间:2020-10-22编辑:脚本学堂
本文分享一例vb.net代码,学习在访问表中遍历记录的实现方法,有需要的朋友参考下。

vb.net实例代码之遍历访问表中的记录。
代码:
 

复制代码 代码示例:
<%@ page language=vb debug=true %>
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.oledb" %>
<script runat=server>
sub page_load(byval sender as object, byval e as eventargs)
    dim dbconn as oledbconnection
    dim dbcommand as oledbdataadapter
    dim dspagedata as new dataset
    dim i as long
    dbconn = new oledbconnection( _
        "provider=microsoft.jet.oledb.4.0;" _
        & "data source=" _
        & server.mappath("employeedatabase.mdb;"))
    dbcommand = new oledbdataadapter _
        ("select * from employee", dbconn)
    dbcommand.fill(dspagedata, _
        "employee")
    for i = 0 to _
        dspagedata.tables("employee").rows.count - 1
        'code to process record
        lblmessage.text = lblmessage.text _
            & "<br>processed record: " _
            & dspagedata.tables("employee"). _
            rows(i).item("id")
    next
end sub
</script>
<html>
<head>
<title>在访问表中遍历记录-www.jb200.com</title>
</head>
<body leftmargin="40">
<form runat="server">
<br><br>
<asp:label
    id="lblmessage"
    runat="server"
/>
</form>
</body>
</html>