注册 登录
编程论坛 ASP技术论坛

这一句返回结果怎么会是这样的?

dhdhzzw 发布于 2008-01-07 12:00, 819 次点击
<%
            dim rsx
            dim sqla
        set    rsx=server.createobject("adodb.recordset")
        sqla="select * from MapInfo where MapID='1' "
        rsx.open sqla,conn,1,1
        response.write(sqla)
        response.end
%>

返回结果为:select * from MapInfo where MapID='1'
应该返回数据库记录集的啊?例如返回MapID='1' 的那条信息啊/。。。。怎么会这样啊?
7 回复
#2
xsz66119352008-01-07 12:50
要全部输出数据库中某一行的内容,只能一个一个字段的输出撒
#3
madpbpl2008-01-07 12:54
明明是输出sql语句啊
#4
lxn3485672482008-01-07 16:25
sql语名
sqla="select * from MapInfo where MapID='1' "不对了,应该是:
sqlq = "select * from MapInfo where MapID = 1"
     response.write(sqla)就是返回sqla  的值了.sqla的值是"select * from MapInfo where MapID='1'
#5
tianyu1232008-01-07 17:11
response.write 是向浏览器输出内容

conn.execute() 执行sql语句
#6
madpbpl2008-01-07 18:43
原帖由 [bold][underline]lxn348567248[/underline][/bold] 于 2008-1-7 16:25 发表 [url=http://bbs.bc-cn.net/redirect.php?goto=findpost&pid=1173847&ptid=196265][/url]
sqla="select * from MapInfo where MapID='1' "不对了,应该是:
sqlq = "select * from MapInfo where MapID = 1"
     response.write(sqla)就是返回sqla  的值了.sqla的值是"select * from MapInfo where MapID='1 ...

对于数字或字符类似1来说,在acc中,加不加单引号是没有影响的,个人看法。
#7
icelovebai2008-01-07 18:45
我倒,用response.write(sqla)输出sqla中的字符串,当然会输出这个啦。。。
#8
xiaoyangyjs2008-01-07 20:04
有人告诉我他错在哪里吗
<style type="text/css">
<!--
.font {
    font-size: 9px;
}
.STYLE1 {font-size: 9pt}
.style4 {color: #FF0000}
-->
</style>
<!--#include file="conn.asp"-->
<%
if request.Form("submit")<>"" then
title=request.form("title")
email=request.form("email")
url=request.form("url")
lianxi=request.form("lianxi")
bodys=request.form("bodys")
set ly=server.createobject("adodb.recordset")
ly.open "select * from liuyan",conn,1,3
ly.addnew
ly("title")=title
ly("email")=email
ly("url")=url
ly("lianxi")=lianxi
ly("bodys")=bodys
ly.update
end if
%>
<body>
<!--#include file="head.htm"-->
<table width="778" border="0" align="center">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><table width="778" border="0" align="center" cellspacing="2" bgcolor="#CCCCCC">
      <tr bgcolor="#F3F3F3">
        <td width="10%" class="STYLE1">NO<font color="#000000">:<%=ly("id")%></font></td>
        <td width="10%" align="right" class="STYLE1">姓名<font color="#000000">:</font></td>
        <td>&nbsp;</td>
      </tr>
      <tr bgcolor="#F3F3F3">
        <td colspan="2" align="right" class="STYLE1" width="20%">主题<font color="#000000">:</font></td>
        <td><%=ly("title")%></td>
      </tr>
      <tr bgcolor="#F3F3F3">
        <td height="90" colspan="2" align="right" class="STYLE1" width="20%">留言内容<font color="#000000">:</font></td>
        <td><%=ly("bodys")%></td>
      </tr>
    </table><br>
    </td>
  </tr>
  <tr>
    <td><form action="" method=post name="form1">
      <table width="778" height="254" border="0" align="center" cellspacing="2" bgcolor="#CCCCCC">
        <tr bgcolor="#F3F3F3">
          <td  width="20%" align=right><span class="STYLE1"><font color="#000000">您的姓名:</font></span></td>
          <td>        </tr>
        <tr bgcolor="#F3F3F3">
          <td   width="20%" align=right bgcolor="#F3F3F3"><span class="STYLE1"> <span class="style4">*</span> 留言主题:</span></td>
          <td ><span class="STYLE1">
            <input name="title" type=text id="title" size="30"  maxlength=50 >
            <span class="style4">* 必须填写(字以内)</span></span></td>
        </tr>
        <tr bgcolor="#F3F3F3">
          <td   width="20%" align=right><span class="STYLE1"><span class="style4">*</span> 您的邮箱:</span></td>
          <td ><input name="email" type="text" id="email" size="30"  maxlength="50">         
          </tr>
        <tr bgcolor="#F3F3F3">
          <td   width="20%" align=right><span class="STYLE1">您的网站:</span></td>
          <td><input name="url" type=text value="http://" size="30"  maxlength=100></td>
        </tr>
        <tr bgcolor="#F3F3F3">
          <td   width="20%" align=right><span class="STYLE1">其它联系方式:</span></td>
          <td><span class="STYLE1">
            <input name="lianxi" type=text id="lianxi" value="" size="30"  maxlength=100>
            (如QQ、MSN等)</span></td>
        </tr>
        <tr bgcolor="#F3F3F3">
          <td   width="20%" align=right><span class="STYLE1"><span class="style4">*</span> 留言内容:<br>
            <font color=red>(100字以内)</font></span></td>
          <td><span style="font-size: 9pt">
            <textarea name="bodys" cols="66" rows="7" id="bodys"></textarea>
          </span></td>
        <tr bgcolor="#F3F3F3">
          <td colSpan="2"><div align="center" class="STYLE1">
              <input type="submit" value="提交留言" name="Submit" onClick="return checked()">
              <input type="reset" value="重新填写" name="Submit2">
          </div></td>
        </tr>
      </table>
    </form></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<!--#include file="foot.htm"-->
</body>
<script language="javascript">
function checked()
{
if(document.form1.title.value=="")
{
document.form1.title.focus();
alert('标题为空!!');
return false;
}
if(document.form1.email.value=="")
{
document.form1.email.focus();
alert('邮箱为空!!');
return false;
}
if(document.form1.bodys.value=="")
{
document.form1.bodys.focus();
alert('内容为空!!');
return false;
}
}
</script>
</html>


我看不出来,这是服务器报错的
错误类型:
Microsoft VBScript 运行时错误 (0x800A000D)
类型不匹配: 'ly'
/web/liuyan.asp, 第 41 行
也就是这一行 <td width="10%" class="STYLE1">NO<font color="#000000">:<%=ly("id")%></font></td>
帮帮忙,我在线等????
1