用ASP和WML来实现数据库查询

Shows how to perform a search with a WAP page and use ASP on the server to do the database query and then
display the results.

1Response.ContentType = "text/vnd.wap.wml"
1<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

 1<card id="UserSearch" title="Search">
 2<p>   
 3Please enter username to find? <input maxlength="15" name="username" type="text"/>
 4<do label="Locate" type="accept">
 5<go href="thispage.asp" method="get">
 6<postfield name="username" value="$username"></postfield>
 7</go>
 8</do>
 9</p>
10</card>   

else
strSQL = "SELECT * FROM tblUsers WHERE Username ='&amp; strWhoIs &amp; '"
Set rs = conn.Execute(strSQL)

1<p>   

if not rs.EOF then
rs.MoveFirst
Response.Write "<strong>User Search Results</strong>"
While not rs.EOF
strFirstName = "First Name " &amp; rs("FirstName")
strLastName = "Last Name " &amp; rs("LastName")
Response.Write strFirstName
Response.Write strLastName
rs.MoveNext
Wend
else
Response.Write "Sorry, no user found."
end if

1</p>
2</card>   

end if

1</wml>
Published At
Categories with Web编程
comments powered by Disqus