asp+access读取前6条记录(VB版)


vbscript脚本版ASP从ACCESS数据库中提取6条数据,测试用数据库文件test.mdb这里下载,程序代码如下:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
dim str
str = ""
dim RECORD_COUNT
dim i
dim conn

Set conn = server.createObject("adodb.connection")
conn.open "provider = microsoft.jet.oledb.4.0; data source = " & server.mapPath("test.mdb")
set rs = server.createObject("adodb.recordset")
rs.open "select top 6 id, title from www_1500km_com", conn, 1, 1
RECORD_COUNT = rs.recordCount
for i = 1 to RECORD_COUNT step 1
  str = str  & i & "," & rs("title") & "<br/>"
  rs.moveNext()
next
rs.close()
set rs = nothing
conn.close()
set conn = nothing

str = str & "===当前是" & RECORD_COUNT & "条记录===" 
response.write str
%>

测试结果如下图: