下面介绍开发数据库检索程序的基本设计方法:
dim conn ‘申明变量
Set Conn=Server.CreatObject("ADODB.Connection") ‘创建链接对象
Dim Rs ‘申明变量
Set Rs=Server.CreatObject("ADODB.Recordset") ‘创建数据对象
Rs.PageSize=10 ‘设置一页所显示的记录数
Dim sql ‘申明变量
<% Response.write(Rs.("Title"))%>或
<%=Rs("Title")%>
Rs.close
Conn.close
Set Rs=nothing
SetConn=nothing
Example.asp
<html>
<head>
</head>
<%
Dim Conn
SetConn = Server.CreateObject("ADODB.Connection")
Conn.Open "book"
Sql= "select * from publication where title like 'ASP%%'"
Dim Rs
Set Rs=Server.CreateObject("ADODB.recordset")
Const adOpenkeyset=1
Rs.Open Sql,Conn, adOpenkeyset
%>
<select size=8>
<%
Do while not Rs.eof
%>
<option><% =Rs("title")%></option>
<%
rs.movenext
loop
%>
</select>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
,信捷职称论文写作发表网