程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> ASP技巧 >> 用ASP和WML來實現數據庫查詢

用ASP和WML來實現數據庫查詢

編輯:ASP技巧
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.


<%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
%>
</wml>
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved