数据库结构如下:
库名:data.mdb
表名:info
字段:id 、企业名称、住所、法定代表人……(这个省略号是等等的意思)
一、反馈页面 hello.asp
源码如下:
<%@ language=vbscript %>
<% response.contenttype="text/vnd.wap.wml" %>
<?xml version="1.0" encoding="gb2312"?>
<!doctype wml public "-//wapforum//dtd wml 1.1//en" "http://www.wapforum.org/dtd/ wml_1.1.xml">
<wml>
<card id="qycx" title="上饶工商信息网">
<p>
请输入查询资料<input name="qycx" type="text" maxlength="16" />
<anchor title="确定">确定
<go href="qycx.asp" method="post">
<postfield name="qycx" value="$qycx"/>
</go>
</anchor>
<br/><br/>
上饶工商信息网
</p>
</card>
</wml>
二、信息接收 页面 qycx.asp
源码如下:
<%@ language=vbscript %>
<% response.contenttype = "text/vnd.wap.wml" %>
<?xml version="1.0" encoding="gb2312"?>
<!doctype wml public "-//wapforum//dtd wml 1.1//en" "http://www.wapforum.org/dtd/ wml_1.1.xml">
<wml>
<card id="qycx2" title="上饶工商信息网">
<p>
<%
qycx=request.form("qycx")
cx="企业名称 like '%"&qycx&"%' "
set conn=server.createobject("adodb.connection")
'conn.open "dsn=qycxsjk;uid=;pwd=;database=data.mdb"
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("qycx.mdb")
sql="select * from info where "&cx&""
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof
%>
<%qymc=rs("企业名称")
id=rs("id")
%>
<a href="qycx2.asp?id=<%response.write id%>" ><%response.write qymc%></a>
<br/>
<%
rs.movenext
loop
rs.close
%>
<br/><br/>
上饶工商信息网
</p>
</card>
</wml>
<% function uni(chinese)
for i = 1 to len (chinese)
a=mid(chinese, i, 1)
uni=uni & "&#x" & hex(ascw(a)) & ";"
next
end function
%>
=========================================================================
第二点评:看到这里,我有点汗,刚开始以“企业名称”做为关键字提交,后来才想到以id为关键字进行查询避免了汉字提交的问题。这么基础一个问题,我居然琢磨了大半天。这里根据hello.asp提交的“企业名称”关键字查询得到所有“企业名称”字段中含有该关键字的企业全称(以免重复),做一个列表,点击将入第三个页面,即该企业详细资料。
三、qycx2.asp
源码如下:
<%@ language=vbscript %>
<% response.contenttype = "text/vnd.wap.wml" %>
<?xml version="1.0" encoding="gb2312"?>
<!doctype wml public "-//wapforum//dtd wml 1.1//en" "http://www.wapforum.org/dtd/ wml_1.1.xml">
<%
set conn=server.createobject("adodb.connection")
'conn.open "dsn=qycxsjk;uid=;pwd=;database=data.mdb"
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("qycx.mdb")
%>
<wml>
<card id="qycx3" title="上饶工商信息网">
<p>
<%
name=request.querystring("id")
sql="select * from info where id="&name&""
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof
%>
<%qymc=rs("企业名称")%>
企业名称:<%response.write qymc%>
<br/>
<%zs=rs("住所")%>
住所:<%response.write zs%>
<br/>
<%fddb=rs("法定代表人")%>
法定代表人:<%response.write fddb%>
<br/>
<%zczb=rs("注册资本")%>
注册资本:<%
if left(zczb,1)="." then
response.write "0"
else
end if
response.write zczb%>万元
<br/>
<%qylx=rs("企业类型")%>
企业类型:<%response.write qylx%>
<br/>
<%jyfw=rs("经营范围")%>
经营范围:<%response.write jyfw%>
<br/>
<%zcrq=rs("成立日期")%>
注册日期:<%response.write zcrq%>
<br/>
<%
rs.movenext
loop
%>
<br/><br/>
上饶工商信息网-end
<br/>
<a href="hello.asp">返回</a>
</p>
</card>
</wml>
=============================================================================
ok,完成查询显示企业详细资料!
写得不好,不要骂我。嘿嘿,欢迎喜欢wap的朋友可以跟我多交流,指导一下!qq:18185813
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器