日期:2014-05-16  浏览次数:20657 次

关于josn 接到参数 执行 sql语句 报错问题
<!--#include file="JSON_2.0.4.asp"-->
<%
Dim member
Set member = jsObject()

dim dbconnection,uplist,DBPath,SQL,Sort,Lbound,Ubound
Dim id=request("jsoncallback")
set dbconnection=Server.CreateObject("ADODB.Connection") 
DBPath = Server.MapPath("a.mdb")
dbconnection.Open "provider=microsoft.jet.oledb.4.0;data source="&dbpath 
'如果 SQL="select ContentID from Content where  ContentID=247"这么写 就能执行
'如果 SQL="select ContentID from Content where  ContentID="&id 就出错,页面显示 语法错误,但是我 单独 访问 这个 asp 能运行 不报错
SQL="select ContentID from Content where  ContentID=247"
SET uplist=dbconnection.EXECUTE(SQL) 
member("code") = ""&uplist(0)&""
member("errmsg") = "\u5bf9\u8c61ID\u4e0d\u5408\u6cd5"
  
response.write request.querystring("jsoncallback")&"("&member.jsString&")"

Set member = Nothing
%>


问题:
'如果 SQL="select ContentID from Content where  ContentID=247"这么写 就能执行,json 接收正常
'如果 SQL="select ContentID from Content where  ContentID="&id 就出错,页面显示 语法错误,但是我 单独 访问 这个 asp 能运行 不报错
   这里 sql 我要 获取动态 数值


请 高手帮助 解决下,我实在是 不知道是哪问题了
------解决方案--------------------
Response.Write SQL
看是否是合法的语句啊
------解决方案--------------------
id数据 ,要么为空,要么就不是数字。

自己检查下id怎么赋值的
------解决方案--------------------
你有 Dim id=request("jsoncallback")
怎么看也不是 id 的值
------解决方案--------------------
你怎么是 var url = 'a.asp?jsoncallback=?'; 呢?
至少也该是 var url = 'a.asp?jsoncallback='+id; 吧