Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)归海一刀
published in(发表于) 2014/3/20 5:15:12
初试WAP之wml+ASP查询_[XML教程]

初试WAP之wml+ASP查询_[XML教程]

搞了这么多年计算机,第一次写文章到网上来!见笑了


程序目的:工作需要,查询企业注册资料的朋友太多了,省得麻烦,在网站上增加了查询功能,居然有人说没有电脑,没电脑也该有个手机吧。用手机查询这样随时随地都行,说干就干,做一个WAP查询,全用记事本写的。


数据库结构如下:


库名:data.mdb


表名:info


字段:id 、企业名称、住所、法定代表人……(这个省略号是等等的意思)


一、反馈页面 hello.asp


源码如下:


<%@ Language=VBScript %>
<% Response.ContentType="text/vnd.wap.wml" %>






请输入查询资料
确定






上饶工商信息网





二、信息接收 页面 qycx.asp


源码如下:


<%@ Language=VBScript %>
<% Response.ContentType = "text/vnd.wap.wml" %>





<%
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")


%>


<%Response.write qymc%>




<%
rs.movenext
loop
rs.close
%>


上饶工商信息网




<% 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" %>



<%
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")
%>





<%
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%>


<%zs=rs("住所")%>
住所:<%Response.write zs%>


<%fddb=rs("法定代表人")%>
法定代表人:<%Response.write fddb%>


<%zczb=rs("注册资本")%>
注册资本:<%
if left(zczb,1)="." then
Response.write "0"
else
end if
Response.write zczb%>万元


<%qylx=rs("企业类型")%>
企业类型:<%Response.write qylx%>


<%jyfw=rs("经营范围")%>
经营范围:<%Response.write jyfw%>


<%zcrq=rs("成立日期")%>
注册日期:<%Response.write zcrq%>



<%
rs.movenext
loop


%>


上饶工商信息网-End


返回





=====================


OK,完成查询显示企业详细资料!


写得不好,不要骂我。嘿嘿,欢迎喜欢WAP的朋友可以跟我多交流,指导一下!


来源:网络







If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759