asp用mysql数据库查询_ASP数据库查询

本文详细解析了一段ASP代码,该代码用于从数据库中检索信息,并展示了如何通过不同的搜索条件来定制查询。介绍了如何使用变量构造SQL查询语句,以及如何处理页面跳转和分页显示等功能。

展开全部

刚好有个相似的,改动改动发给你!

search.asp:

 姓名精确模糊62616964757a686964616fe59b9ee7ad9431333234326431
身份证

>精确模糊

 日期精确模糊
 工资精确模糊

查找

————————————————————

show.asp:

dim bname,btype,pname,ptype,aname,atype,mname,mtype,continue,currentpage,rowcount,i

continue=0

currentpage=Trim(Request("gopage"))

If currentpage="" then currentpage=1

bname=Trim(Request("bookname"))

btype=Trim(Request("booktype"))

pname=Trim(Request("publisher"))

ptype=Trim(Request("pubtype"))

aname=Trim(Request("author"))

atype=Trim(Request("auttype"))

mname=Trim(Request("money"))

mtype=Trim(Request("moneytype"))

IF bname="" and pname="" and aname="" and mname="" then Response.Redirect "请填入信息!"

mySQL="select * from aa where "

IF bname<>"" then

IF btype=1 then

mySQL=mySQL & "姓名='" & bname & "'"

continue=1

else

mySQL=mySQL & "姓名 like '%" & bname & "%'"

continue=1

End IF

End IF

IF pname<>"" then

IF continue=1 then mySQL=mySQL & "and "

IF ptype=1 then

mySQL=mySQL & "身份证号='" & pname & "'"

continue=1

else

mySQL=mySQL & "身份证号 like '%" & pname & "%'"

continue=1

End IF

End IF

IF aname<>"" then

IF continue=1 then mySQL=mySQL & "and "

IF atype=1 then

mySQL=mySQL & "参加工作日期='" & aname & "'"

else

mySQL=mySQL & "参加工作日期 like '%" & aname & "%'"

End IF

End IF

IF mname<>"" then

IF continue=1 then mySQL=mySQL & "and "

IF mtype=1 then

mySQL=mySQL & "基本工资='" & mname & "'"

else

mySQL=mySQL & "基本工资 like '%" & mname & "%'"

End IF

End IF

%>

title.gif
姓名身份证号参加工作日期基本工资

Set Con=Server.CreateObject("ADODB.Connection")

con.Open "DSN=xhnew.mdb;DBQ=D:\..\xhnew.mdb;DriverId=25;FIL=MSAccess;MaxBufferSize=2048;"

set RS=Server.CreateObject("ADODB.RecordSet")

RS.Open mySQL,Con,adOpenStatic

RS.PageSize=15

IF not RS.EOF then RS.AbsolutePage=cInt(currentpage)

rowcount=0

While not RS.EOF and rowcount

year1=Year(RS("参加工作日期"))

month1=Month(RS("参加工作日期"))

day1=Day(RS("参加工作日期"))

%>

rowcount=rowcount+1

RS.MoveNext

Wend

For i=rowcount+1 to RS.PageSize

%>

    

Next

%>

Response.write(currentpage)

%>

页/

IF RS.PageCount>0 then

Response.write(RS.PageCount)

else

Response.write("1")

End IF

%>

dim prepage,nextpage

prepage=cInt(currentpage)-1

nextpage=cInt(currentpage)+1

IF cInt(currentpage)>1 then

Response.write("上一页" )

else

Response.write("上一页")

End IF

%>

IF cInt(currentpage)

Response.write("下一页" )

else

Response.write("下一页")

End IF

Con.Close

set RS=NOTHING

%>

关闭窗口

没人喜欢做问答题,谁都喜欢做选择题!要自己勤动手!

2Q==

已赞过

已踩过<

你对这个回答的评价是?

评论

收起

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值