asp做多条件查询时出错
代码如下:sql="select*fromcourses,col,dep,spewhere1=1andcourses.colid=col.cidandcourses.de...
代码如下:
sql="select*from courses, col,dep,spe where 1=1 and courses.colid=col.cid and courses.depid=dep.coid and courses.speid=spe.sid"
if Request.form("textfield") <>"" then
sql= sql & " and col.c_name like ’%"& trim(Request.form("textfield")) &"%’"
end if
if Request.form("textfield2") <>"" then
sql= sql & " and dep.d_name like ’%"& trim(Request.form("textfield2")) &"%’"
end if
if Request.form("textfield3") <>"" then
sql= sql & " and spe.s_name like ’%"& trim(Request.form("textfield3")) &"%’"
end if
if Request.form("textfield4") <>"" then
sql= sql & " and courses.no="& trim(Request.form("textfield4")) &""
end if
if Request.form("textfield5") <>"" then
sql= sql & " and courses.course like ’%"& trim(Request.form("textfield5")) &"%’"
end if
if Request.form("textfield6") <>"" then
sql= sql & " and courses.cha=’"& trim(Request.form("textfield6")) &"’"
end if
if Request.form("textfield7") <>"" then
sql= sql & " and courses.point="& trim(Request.form("textfield7")) &""
end if
if Request.form("textfield8") <>"" then
sql= sql & " and courses.tim="& trim(Request.form("textfield8")) &""
end if
set rs=Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.open sql,conn,1,1
提示错误:Microsoft OLE DB Provider for SQL Server (0x80040E14)
第 1 行: '’' 附近有语法错误。
请高手指点! 展开
sql="select*from courses, col,dep,spe where 1=1 and courses.colid=col.cid and courses.depid=dep.coid and courses.speid=spe.sid"
if Request.form("textfield") <>"" then
sql= sql & " and col.c_name like ’%"& trim(Request.form("textfield")) &"%’"
end if
if Request.form("textfield2") <>"" then
sql= sql & " and dep.d_name like ’%"& trim(Request.form("textfield2")) &"%’"
end if
if Request.form("textfield3") <>"" then
sql= sql & " and spe.s_name like ’%"& trim(Request.form("textfield3")) &"%’"
end if
if Request.form("textfield4") <>"" then
sql= sql & " and courses.no="& trim(Request.form("textfield4")) &""
end if
if Request.form("textfield5") <>"" then
sql= sql & " and courses.course like ’%"& trim(Request.form("textfield5")) &"%’"
end if
if Request.form("textfield6") <>"" then
sql= sql & " and courses.cha=’"& trim(Request.form("textfield6")) &"’"
end if
if Request.form("textfield7") <>"" then
sql= sql & " and courses.point="& trim(Request.form("textfield7")) &""
end if
if Request.form("textfield8") <>"" then
sql= sql & " and courses.tim="& trim(Request.form("textfield8")) &""
end if
set rs=Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.open sql,conn,1,1
提示错误:Microsoft OLE DB Provider for SQL Server (0x80040E14)
第 1 行: '’' 附近有语法错误。
请高手指点! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询