搞了这么多年计算机,第一次写文章到网上来!见笑了
程序目的:工作需要,查询企业注册资料的朋友太多了,省得麻烦,在网站上增加了查询功能,居然有人说没有电脑,没电脑也该有个手机吧。用手机查询这样随时随地都行,说干就干,做一个WAP查询,全用记事本写的。
数据库结构如下:
库名:data.mdb
表名:info
字段:id 、企业名称、住所、法定代表人……(这个省略号是等等的意思)
一、反馈页面 hello.asp
源码如下:
1@ Language=VBScript
1 Response.ContentType="text/vnd.wap.wml"
1<wml>
2<card id="qycx" title="上饶工商信息网">
3<p>
4请输入查询资料<input maxlength="16" name="qycx" type="text"/>
5<anchor title="确定">确定
6<go href="qycx.asp" method="post">
7<postfield name="qycx" value="$qycx"></postfield>
8</go>
9</anchor>
10
11
12
13
14上饶工商信息网
15</p>
16</card>
17</wml>
二、信息接收 页面 qycx.asp
源码如下:
1@ Language=VBScript
1 Response.ContentType = "text/vnd.wap.wml"
1<wml>
2<card id="qycx2" title="上饶工商信息网">
3<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")
1
2<a href="qycx2.asp?id=```
3Response.write id
4```">```
5Response.write qymc
6```</a>
7
8
9
rs.movenext
loop
rs.close
1
2
3
4上饶工商信息网
5</p>
6</card>
7</wml>
1 Function uni(Chinese)
2For i = 1 to Len (Chinese)
3a=Mid(Chinese, i, 1)
4uni=uni & "&#x" & Hex(Ascw(a)) & ";"
5next
6End Function
=================================================
第二点评:看到这里,我有点汗,刚开始以“企业名称”做为关键字提交,后来才想到以ID为关键字进行查询避免了汉字提交的问题。这么基础一个问题,我居然琢磨了大半天。这里根据hello.asp提交的“企业名称”关键字查询得到所有“企业名称”字段中含有该关键字的企业全称(以免重复),做一个列表,点击将入第三个页面,即该企业详细资料。
三、qycx2.asp
源码如下:
1@ Language=VBScript
1 Response.ContentType = "text/vnd.wap.wml"
1
2Set conn=Server.CreateObject("adodb.connection")
3'conn.Open "dsn=qycxsjk;uid=;pwd=;database=data.mdb"
4conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("qycx.mdb")
1<wml>
2<card id="qycx3" title="上饶工商信息网">
3<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("企业名称")
1企业名称:```
2Response.write qymc
1zs=rs("住所")
住所:``` Response.write zs
fddb=rs("法定代表人")
1法定代表人:```
2Response.write fddb
1zczb=rs("注册资本")
注册资本:```
if left(zczb,1)="." then
Response.write "0"
else
end if
Response.write zczb
qylx=rs("企业类型")
1企业类型:```
2Response.write qylx
1jyfw=rs("经营范围")
经营范围:``` Response.write jyfw
zcrq=rs("成立日期")
1注册日期:```
2Response.write zcrq
1
2rs.movenext
3loop
上饶工商信息网-End
``` =====================OK,完成查询显示企业详细资料!
写得不好,不要骂我。嘿嘿,欢迎喜欢WAP的朋友可以跟我多交流,指导一下!QQ:18185813