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

这样的ASP代码有错吗?请各位大虾指点!!!急!!!

wxm198427 发布于 2008-09-05 14:30, 1007 次点击
<!--#include file="conn.asp"-->

<%
dim rs,sql,id,title,content
id=cint(request.querystring("id"))
set rs=server.CreateObject("adodb.recordset")
sql="select * from nd_msg where id="&id
rs.open sql,conn,1,3
if not(rs.eof and rs.bof) then
title=rs("nd_title")
content=rs("nd_content")
response.write title
response.write  content
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%end if%>
<a href="weiduyoujian.asp">返回</a>

[[it] 本帖最后由 wxm198427 于 2008-9-5 14:32 编辑 [/it]]
14 回复
#2
yms1232008-09-05 14:34
没错阿?
#3
yms1232008-09-05 14:35
如果说错误那就可能是id=cint(request.querystring("id"))这句话没有获得传过来的数据,检查提交页面的编写
#4
wxm1984272008-09-05 14:36
就是啊
就是啊,但是从运行的结果看,除了返回两个字就什么都没有了,知道吗
那些个从数据库中调出的那些东东都不知道哪去了????
谁能告诉我????????????
#5
wxm1984272008-09-05 14:37
我也怀疑
我也很怀疑这个语句!!!!!!!
#6
yms1232008-09-05 14:40
那只能说问题并不出在楼主提供源代码的网页上,出在向这个页面提交数据的网页上
#7
wxm1984272008-09-05 15:59
谢谢各位兄弟姐妹
我知道了,我做出来了,谢谢3楼那位兄弟给我的灵感,是我自己粗心了,少了传递值的代号,是在前面一个页面的,嗨,都弄了我好半天,后面的语句绝对没有一点错,我都运行成功了,告诫自己,各位,粗心不的啊!!
#8
wxm1984272008-09-05 16:14
还有错误啊哥们兄弟姐妹门啊
你们看,这样的代码也说FROM子句语法错误,就下面的那个sql语句,我都无语了,各位帮我看看:
<!--#include file="conn.asp"-->
<%
dim rs,sql,name,password
name=trim(request.form("name"))
password=trim(request.form("password"))
if name<>"" and  password<>"" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from user where name='"&name&"'"
rs.open sql,conn,1,3
if not(rs.eof and rs.bof) then
response.write "用户名存在"
else
rs.addnew
rs("name")=name
rs("password")=password
rs.update
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
else
response.write "用户名和密码不能为空!"
response.end()
end if
%>
#9
永夜的极光2008-09-05 16:39
user外面要加一对中括号,改成
sql="select * from [user] where name='"&name&"'"
#10
wxm1984272008-09-05 17:17
谢谢楼上的大哥
谢谢楼上的哥们,我试试看,我平时都不用什么[]把那个给括起来啊,不过我还是去试试看!!谢谢
#11
wxm1984272008-09-05 17:20
谢谢楼上的大哥
我按你的做法搞定了,谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢
#12
yms1232008-09-05 20:39
sql="select * from [user] where name='"&name&"'"
user是SQL语句关键字用作表名要加[]中括号以区分
#13
yangzeng2008-09-05 21:25
最好把
改成这样

set rs=server.CreateObject("adodb.recordset")
sql="select * from nd_msg where id="&cint(request.querystring("id"))
#14
awke0022008-09-06 09:18
[bo][un]yms123[/un] 在 2008-9-5 20:39 的发言:[/bo]

sql="select * from  where name='"&name&"'"
user是SQL语句关键字用作表名要加[]中括号以区分

这个平时到没怎么注意。。
难怪总老出错。。。
#15
wxm1984272008-09-09 10:28
谢谢
请问13楼的哥们,为什么要把那个语句改成你说的那个呢,我不明白个中道理还有好处,请明示!!!谢谢
1