asp程序关于范围查询代码?
我有个网站关于范围查询就是不用查出来.<%DimRs,Sql,actionDimstuffname,stuffdesc,factoryin,pagel,thickness...
我有个网站关于范围查询就是不用查出来.
<%
Dim Rs,Sql,action
Dim stuffname,stuffdesc,factoryin,pagel,thicknessmin,thicknessmax,broadmin,broadmax,footagemin,footagemax,footage
Dim i,intPage,page,pre,last,filepath
action=request("action")
stuffname = Server.HTMLEncode(trim(request("stuffname")))
stuffdesc = Server.HTMLEncode(trim(request("stuffdesc")))
factoryin = Server.HTMLEncode(trim(request("factoryin")))
pagel = Server.HTMLEncode(trim(request("pageline")))
thicknessmin = Server.HTMLEncode(trim(request("thicknessmin")))
thicknessmax = Server.HTMLEncode(trim(request("thicknessmax")))
broadmin = Server.HTMLEncode(trim(request("broadmin")))
broadmax = Server.HTMLEncode(trim(request("broadmax")))
footagemin = Server.HTMLEncode(trim(request("footagemin")))
footagemax = Server.HTMLEncode(trim(request("footagemax")))
Sql = "select * from metals where 1=1 "
if action = "" then
Sql = Sql + " order by id "
end if
if action = "search" then
if stuffname <> "" then
Sql = Sql + " and stuffname like '%" & stuffname &"%'"
end if
if stuffdesc <> "" then
Sql = Sql + " and stuffdesc like '%" & stuffdesc &"%'"
end if
if factoryin <> "" then
Sql = Sql + " and factoryin like '%" & factoryin &"%'"
end if
if thicknessmin <> "" then
Sql = Sql + " and thickness>=" & thicknessmin
end if
if thicknessmax <> "" then
Sql = Sql + " and thickness <=" & thicknessmax
end if
if broadmin <> "" then
Sql = Sql + " and broad>=" & broadmin
end if
if broadmax <> "" then
Sql = Sql + " and broad <=" & broadmax
end if
if footagemin <> "" then
Sql = Sql + " and footage like '%" & footagemin &"%'"
end if
if footagemax <> "" then
Sql = Sql + " and footage like '%" & footagemin &"%'"
end if
Sql = Sql + " order by id "
end if
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.PageSize = 20
if pagel <>"" then
Rs.PageSize = pagel
end if
Rs.CuRsorLocation = 3
Rs.Open sql,conn,0,2,1
pre = true
last = true
page = trim(Request.QueryString("page"))
%> 展开
<%
Dim Rs,Sql,action
Dim stuffname,stuffdesc,factoryin,pagel,thicknessmin,thicknessmax,broadmin,broadmax,footagemin,footagemax,footage
Dim i,intPage,page,pre,last,filepath
action=request("action")
stuffname = Server.HTMLEncode(trim(request("stuffname")))
stuffdesc = Server.HTMLEncode(trim(request("stuffdesc")))
factoryin = Server.HTMLEncode(trim(request("factoryin")))
pagel = Server.HTMLEncode(trim(request("pageline")))
thicknessmin = Server.HTMLEncode(trim(request("thicknessmin")))
thicknessmax = Server.HTMLEncode(trim(request("thicknessmax")))
broadmin = Server.HTMLEncode(trim(request("broadmin")))
broadmax = Server.HTMLEncode(trim(request("broadmax")))
footagemin = Server.HTMLEncode(trim(request("footagemin")))
footagemax = Server.HTMLEncode(trim(request("footagemax")))
Sql = "select * from metals where 1=1 "
if action = "" then
Sql = Sql + " order by id "
end if
if action = "search" then
if stuffname <> "" then
Sql = Sql + " and stuffname like '%" & stuffname &"%'"
end if
if stuffdesc <> "" then
Sql = Sql + " and stuffdesc like '%" & stuffdesc &"%'"
end if
if factoryin <> "" then
Sql = Sql + " and factoryin like '%" & factoryin &"%'"
end if
if thicknessmin <> "" then
Sql = Sql + " and thickness>=" & thicknessmin
end if
if thicknessmax <> "" then
Sql = Sql + " and thickness <=" & thicknessmax
end if
if broadmin <> "" then
Sql = Sql + " and broad>=" & broadmin
end if
if broadmax <> "" then
Sql = Sql + " and broad <=" & broadmax
end if
if footagemin <> "" then
Sql = Sql + " and footage like '%" & footagemin &"%'"
end if
if footagemax <> "" then
Sql = Sql + " and footage like '%" & footagemin &"%'"
end if
Sql = Sql + " order by id "
end if
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.PageSize = 20
if pagel <>"" then
Rs.PageSize = pagel
end if
Rs.CuRsorLocation = 3
Rs.Open sql,conn,0,2,1
pre = true
last = true
page = trim(Request.QueryString("page"))
%> 展开
1个回答
展开全部
经常会在连接DB的时候用到,就是不知道代表什么意思。。。
RS.OPEN SQL,CONN,A,B
A:
ADOPENFORWARDONLY(=0)
只读,且当前数据记录只能向下移动
ADOPENKEYSET(=1)
只读,当前数据记录可自由移动
ADOPENDYNAMIC(=2)
可读写,当前数据记录可自由移动
ADOPENSTATIC(=3)
可读写,当前数据记录可自由移动,可看到新增记录
B:
ADLOCKREADONLY(=1)
缺省锁定类型,记录集是只读的,不能修改记录
ADLOCKPESSIMISTIC(=2)
悲观锁定,当修改记录时,数据提供者将尝试锁定记录以确保成功地编辑记录。只要编辑一开始,则立即锁住记录。
ADLOCKOPTIMISTIC(=3)
乐观锁定 ,直到用Update方法提交更新记录时才锁定记录。
ADLOCKBATCHOPTIMISTIC(=4)
批量乐观锁定,允许修改多个记录,只有调用UpdateBatch方法后才锁定记录。
当不需要改动任何记录时,应该使用只读的记录集,这样提供者不用做任何检测。
对于一般的使用,乐观的锁定可能是最好的选择,因为记录只被锁定一小段时间,
数据在这段时间被更新。这减少了资源的使用。
另外,你没有指定Rs.absolutepage=
RS.OPEN SQL,CONN,A,B
A:
ADOPENFORWARDONLY(=0)
只读,且当前数据记录只能向下移动
ADOPENKEYSET(=1)
只读,当前数据记录可自由移动
ADOPENDYNAMIC(=2)
可读写,当前数据记录可自由移动
ADOPENSTATIC(=3)
可读写,当前数据记录可自由移动,可看到新增记录
B:
ADLOCKREADONLY(=1)
缺省锁定类型,记录集是只读的,不能修改记录
ADLOCKPESSIMISTIC(=2)
悲观锁定,当修改记录时,数据提供者将尝试锁定记录以确保成功地编辑记录。只要编辑一开始,则立即锁住记录。
ADLOCKOPTIMISTIC(=3)
乐观锁定 ,直到用Update方法提交更新记录时才锁定记录。
ADLOCKBATCHOPTIMISTIC(=4)
批量乐观锁定,允许修改多个记录,只有调用UpdateBatch方法后才锁定记录。
当不需要改动任何记录时,应该使用只读的记录集,这样提供者不用做任何检测。
对于一般的使用,乐观的锁定可能是最好的选择,因为记录只被锁定一小段时间,
数据在这段时间被更新。这减少了资源的使用。
另外,你没有指定Rs.absolutepage=
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询