邱露白领堕落日记全文:这句不对么?sql="select*form main where id ="+idx

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/07 12:03:21
请问一下,SQL语言不能叫这样写么?
我在做一个跨页连接的ASP文件
不好意思,我的源代码是
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<% dim idx
idx="1"
if (request("id")<>"") then
idx=request("id")
end if
%>
<% sql="select*form main where id ="+idx
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>

我照五楼的修改了,还是不行啊
出现的错误信息是:
错误类型:
Microsoft JET Database Engine (0x80040E14)
语法错误 (操作符丢失) 在查询表达式 '* form main where id =1' 中。
/zy.asp, 第 11 行

啊啊啊啊,还不行啊。
fengyunhualong加我QQ好吗?我把我的文件整个传给你, 你帮我看一下撒~
QQ:54968771
谢谢了

按照你上面的,你的id字段必须得是数值型的,idx也必须是数值型的。
如果他们两个都是数值型的,而且你肯定其它没有错误,那就是你少了两个空格的错误。
也就是你在“select”和“*”后都少了空格,应该是:
sql="select * from main where id="&idx

而且还有一个单词错误:
不是form
而是from
你的idx不是现在数值型的,而是字符型的,
你在
if (request("id")<>"") then
idx=request("id")
end if
后再加句:
idx=Cint(idx)
把它转为数值型的,应该就OK了
也就是:
if (request("id")<>"") then
idx=request("id")
end if
idx=Cint(idx)
sql="select * from main where id ="&idx
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<% dim idx
idx=1
if (request("id")<>"") then
idx=request("id")
end if
%>
<% sql="select * from main where id="&idx
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>

我帮你分析一下啊
form 是错了
应该是from
但是main 和id好象都是关键字吧
是不是把它放到中括号里
sql="select*form [main] where [id] =" & cint(idx)
如果是字符类型的就
sql="select*form [main] where [id] ='" & idx & "'"

idx的类型是什么。是字符串还是数值型 ??如果是数值型 的需要转换为Cstr(idx)。。应该94这个原因吧。。我想。。祝好运。。

单看这一句没什么可说的。我也不知道你的 ID 字段是什么类型的。

select * from main where id=
??
不是很明白你的意思。