当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用ASP和WML来实现数据库查询

ASP
保护 XML Web 服务免受黑客攻击
开发BtoC电子商务系统(ASP.NET)
用asp.net实现的把本文推荐给好友功能
尝尝ASP.NET中的小甜饼
web.config一个中文解释
使用ASP.NET加密口令
在SQL Server中保存和输出图片
ASP 中健壮的页结构的异常处理
如何使你的机器运行ASP?
asp(Active Server Page)的语言特性
关于inc文件
IE4 的 模 式 对 话 框 设 计
亲密接触ASP.net(6)
亲密接触ASP.Net(7)
用ASP.Net写一个发送ICQ信息的程序
用ASP.Net编写的查询域名的程序
使用 ASP+ 列表绑定控件(上)
使用 ASP+ 列表绑定控件(中)
使用 ASP+ 列表绑定控件(下)
揭开ASP神秘面纱(1)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 47 ::
收藏到网摘: n/a

       贴一段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
  %>