散弹枪弹药种类:asp关于页面变量传递的问题,急,高分

来源:百度文库 编辑:高校问答 时间:2024/04/29 11:43:47
<%
ic=Request.QueryString("ic")
set rs=server.createobject("adodb.recordset")
sql="select * from sa where ic = "&ic
rs.open sql,conn,1,1
if not rs.eof then

else
response.write "此内容不存在!"
response.end
end if
%>

在页面的能用<%=ic%>接收传递过来的变量,但用<%=rs("")%>显示sa 表里的数据时却显示不出来,如果嫌分低我再加.

你把
sql="select * from sa where ic = "&ic
改成
sql="select * from sa where ic = '"&ic&"'"
试一试,不行我摔死

对 接受传递没有错误。
你的ic字段是不是字符串类型,如果是 则需要 ic='"&ic&"'
但是看你想怎么输出,我看你的语句似乎想在别的地方输出 而不是在
if not rs.eof then 之后。 这样的话 你可以首先定义一个变量。
dim var1
var1=rs("子段名")

然后在你想输出的地方 输入 <%=var1%>
ok

是啊,字符串要加双引号的,把sql="select * from sa where ic = "&ic改成sql="select * from sa where ic = '"&ic&"'"

1\
<%
ic=Request.QueryString("ic")
set rs=server.createobject("adodb.recordset")
sql="select * from sa where ic = "&ic 'ic必须是数字才能这样用,如果是字符串就得用ic='"&ic&"''了.
rs.open sql,conn,1,1 '1,1方式不能对数据库写;1,3方式可以读写数据库.
if not (rs.eof and rs.bof) then
response.write ic
response.write rs("name")'这样可以输出name字段,如要用<%=rs("name")%>用以下方式.
else
response.write "此内容不存在!"
response.end
end if
%>
2\
<%
ic=Request.QueryString("ic")
set rs=server.createobject("adodb.recordset")
sql="select * from sa where ic = "&ic 'ic必须是数字才能这样用,如果是字符串就得用ic='"&ic&"''了.
rs.open sql,conn,1,1 '1,1方式不能对数据库写;1,3方式可以读写数据库.
if not (rs.eof and rs.bof) then
response.write ic
%>
<%=rs("name")%>
<%
else
response.write "此内容不存在!"
response.end
end if
%>
3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!3\注意sa可能是语言关键字,换成其它的试试!

3\注意sa可能是语言关键字,换成其它的试试!