ASP问题,数据库多条件查询
<%@Language=VBScript%><%optionexplicit%><!--#includefile="conn.asp"--><!--#includefil...
<%@ Language=VBScript %>
<% option explicit %>
<!--#include file="conn.asp"-->
<!--#include file="Checkadmin.asp"-->
<%
dim strid,strsname,strpname
dim sql1,rs1,rs,sql,rs2,sql2
dim subjectname
dim number
dim curpage, i,page
subjectname=trim(request("subjectname"))
strid=request.querystring("id")
strsname=request.querystring("sname")
strpname=request.querystring("pname")
if request("action")="edit" then
set rs=server.createobject("ADODB.recordset")
rs.open "select * from tk where id = " & strid, conn,1,3
rs("fenshu")=request("fenshu")
rs.update
rs.close
set rs=nothing
set rs2=server.createobject("adodb.recordset")
rs2.open "select * from score where studentname = '" & strsname &"' and where subjectname ='" & strpname &"'", conn,1,3
rs2("score")=rs2("score")+ request("fenshu")
rs2.update
rs2.close
set rs2=nothing
end if
%>
<html>
<head>
<title>纪录</title>
<link href="../style.css" rel="stylesheet" type="text/css"></head>
<body background=../images/backimage.gif >
<table width="100%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor=blue>
<tr>
<td width="10%"> <div align="center">姓名</div></td>
<td width="15%"> <div align="center">科目</div></td>
<td width="10%"> <div align="center">类型</div></td>
<td width="50%"> <div align="center">应答</div></td>
<td width="5%"> <div align="center">分数</div></td>
<td width="10%"> <div align="center">操作</div></td>
</tr>
<%
'列表
set rs1=server.createobject("adodb.recordset")
rs1.open "select * from tk order by id desc ",conn,1,1
if err.number <> 0 then
response.write "数据库出错"
elseif rs1.bof and rs1.eof then
rs1.close
response.write "目前没有纪录"
else
do while not rs1.eof
%>
<tr>
<% if rs1("key")=0 then %>
<form name="form" action="mgtkscore.asp?id=<%=rs1("id")%>?pname=<%=rs1("projectname")%>?sname=<%=rs1("studentname")%>&action=edit" method="post">
<td height="21" > <div align="center"><%=rs1("studentname")%></div></td>
<td height="21" > <div align="center"><%=rs1("projectname")%></div></td>
<td height="21" > <div align="center"><%=rs1("leixing")%></div></td>
<td height="21" > <div align="center"><%=rs1("answer")%></div></td>
<td height="21" > <div align="center"><input type="text" name="fenshu" size="4" value="<%=rs1("fenshu")%>"></div></td>
<td height="21" > <div align="center"><input type="submit" value="提交" name="submit" ></div></td></form>
<%end if%>
</tr>
<%
rs1.movenext
loop
end if
%>
</table>
<%
rs1.close
set rs1=nothing
%>
</body>
</html>
这是页面程序,但是运行出来的结果出错:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'studentname = '' and where subjectname =''' 中。
/cs/exam/admin/mgtkscore.asp, 第 25 行
哪位高人能帮忙啊,谢谢
我知道为空,要怎么改呢?
where删除掉之后,还是出错,这次出错提示是:Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver]COUNT 字段不正确 ,18行,也就是 rs.open "select * from tk where id = " & strid , conn,1,3这段! 展开
<% option explicit %>
<!--#include file="conn.asp"-->
<!--#include file="Checkadmin.asp"-->
<%
dim strid,strsname,strpname
dim sql1,rs1,rs,sql,rs2,sql2
dim subjectname
dim number
dim curpage, i,page
subjectname=trim(request("subjectname"))
strid=request.querystring("id")
strsname=request.querystring("sname")
strpname=request.querystring("pname")
if request("action")="edit" then
set rs=server.createobject("ADODB.recordset")
rs.open "select * from tk where id = " & strid, conn,1,3
rs("fenshu")=request("fenshu")
rs.update
rs.close
set rs=nothing
set rs2=server.createobject("adodb.recordset")
rs2.open "select * from score where studentname = '" & strsname &"' and where subjectname ='" & strpname &"'", conn,1,3
rs2("score")=rs2("score")+ request("fenshu")
rs2.update
rs2.close
set rs2=nothing
end if
%>
<html>
<head>
<title>纪录</title>
<link href="../style.css" rel="stylesheet" type="text/css"></head>
<body background=../images/backimage.gif >
<table width="100%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor=blue>
<tr>
<td width="10%"> <div align="center">姓名</div></td>
<td width="15%"> <div align="center">科目</div></td>
<td width="10%"> <div align="center">类型</div></td>
<td width="50%"> <div align="center">应答</div></td>
<td width="5%"> <div align="center">分数</div></td>
<td width="10%"> <div align="center">操作</div></td>
</tr>
<%
'列表
set rs1=server.createobject("adodb.recordset")
rs1.open "select * from tk order by id desc ",conn,1,1
if err.number <> 0 then
response.write "数据库出错"
elseif rs1.bof and rs1.eof then
rs1.close
response.write "目前没有纪录"
else
do while not rs1.eof
%>
<tr>
<% if rs1("key")=0 then %>
<form name="form" action="mgtkscore.asp?id=<%=rs1("id")%>?pname=<%=rs1("projectname")%>?sname=<%=rs1("studentname")%>&action=edit" method="post">
<td height="21" > <div align="center"><%=rs1("studentname")%></div></td>
<td height="21" > <div align="center"><%=rs1("projectname")%></div></td>
<td height="21" > <div align="center"><%=rs1("leixing")%></div></td>
<td height="21" > <div align="center"><%=rs1("answer")%></div></td>
<td height="21" > <div align="center"><input type="text" name="fenshu" size="4" value="<%=rs1("fenshu")%>"></div></td>
<td height="21" > <div align="center"><input type="submit" value="提交" name="submit" ></div></td></form>
<%end if%>
</tr>
<%
rs1.movenext
loop
end if
%>
</table>
<%
rs1.close
set rs1=nothing
%>
</body>
</html>
这是页面程序,但是运行出来的结果出错:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'studentname = '' and where subjectname =''' 中。
/cs/exam/admin/mgtkscore.asp, 第 25 行
哪位高人能帮忙啊,谢谢
我知道为空,要怎么改呢?
where删除掉之后,还是出错,这次出错提示是:Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver]COUNT 字段不正确 ,18行,也就是 rs.open "select * from tk where id = " & strid , conn,1,3这段! 展开
3个回答
展开全部
一看枝庆缓就只SQL语句不对,多了个where
rs2.open "select * from score where studentname = '" & strsname &"差芹'猛模 and subjectname ='" & strpname &"'"
rs2.open "select * from score where studentname = '" & strsname &"差芹'猛模 and subjectname ='" & strpname &"'"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
studentname为空或者subjectname为空,你测试一下.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询