贴一段asp和wml查询数据库得代码,大家参考参考,其实跟asp写web页面很相似得。
<%response.contenttype = “text/vnd.wap.wml”%>
<?xml version=”1.0″?><!doctype wml public “-//wapforum//dtd wml 1.1//en” “http://www.wapforum.org/dtd/wml_1.1.xml”>
<wml>
<%
dim conn, rs
dim strsql,strfirstname, strlastname
set conn = server.createobject(“adodb.connection”)
set rs = server.createobject(“adodb.recordset”)
conn.open session(“myconnect_string”) replace with your connect string
strwhois = request.querystring(“username”)
if strwhois=”” then
%>
<card id=”usersearch” title=”search”>
<p>
please enter username to find? <input name=”username” type=”text” maxlength=”15″/>
<do type=”accept” label=”locate”>
<go href=”thispage.asp” method=”get”>
<postfield name=”username” value=”$username”/>
</go>
</do>
</p>
</card>
<%
else
strsql = “select * from tblusers where username =& strwhois & “
set rs = conn.execute(strsql)
%> <card id=”userresult” title=”result”>
<p>
<%
if not rs.eof then
rs.movefirst
response.write “<strong>user search results</strong>”
while not rs.eof
strfirstname = “first name ” & rs(“firstname”)
strlastname = “last name ” & rs(“lastname”)
response.write strfirstname
response.write strlastname
rs.movenext
wend
else
response.write “sorry, no user found.”
end if
%>
</p>
</card>
<%
end if
%>
