这个asp程序有错吗?

来源:百度知道 编辑:UC知道 时间:2024/06/25 11:52:24
<html>
<head>
</head>

<%section1=request.form("setion")
content1=request.form("content")
%>
<%

set conn=server.createobject("adodb.connection")
conn.open "phone"
sql="select * from phone_record where "§ion1&"=""&content1&"""
set rs=conn.execute(sql)
%>

<p>查询时间:<%=now%>
<table border=2>
<font color=#213554><tr>
<%for i=0 to rs.fields.count-1%>
<td><b><%=rs(i).name%></b></td>
<%next%>
</tr></font>
<%do while not rs.eof%>
<tr>
<%for i=0 to rs.fields.count-1%>
<td valign=top><%=rs(i)%></td>
<%next%>
</tr>
<%
rs.movenext
loop
rs.close
conn.close
%>
</table>

确认phone 数据源设置好 ,如果设置好了,就没有问题
其次
select * from phone_record where "§ion1&"=""&content1&""" 确信输入对了?
§这个符号应该不是你想要的吧
你应该是想查询 section1=content1 这样的关系吧
select * from phone_record where "&setion1&"='"&content1&"'" 应该这样写,注意单双引号

我标记的地方是所改的地方

<html>
<head>
</head>

<body>
<%section1=trim(request.form("setion")) '把左右空格去掉
content1=trim(request.form("content")) '把左右空格去掉
%>
<%

set conn=server.createobject("adodb.connection")
conn.open "phone" '这里我不知你连接的对不对,但下面我给你一些连接数据库的方法
sql="select * from phone_record where " & section1 & "='" & content1 & "'" '双引号里的双引号改为单引号
set rs=conn.execute(sql)
%>

<p>查询时间:<%=now%>
<table border=2>
<tr>
<%f