哈萨克斯坦城市:关于asp的问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 14:32:10
<%
id=request.QueryString("gonggaoid")
gonggaotext=request.Form("gonggaotext")
gonggaourl=request.Form("gonggaourl")
if gonggaotext="" then
response.Write "请输入文本!"
response.end
end if
if gonggaourl="" then
response.write "请输入链接地址!"
response.end
end if
sql1="update gonggao set gonggaotext='"&gonggaotext&"',gonggaourl='"&gonggaourl&"' where id='"&id&"'"
set conn= Server.CreateObject("adodb.connection")
dbpath="E:\userdata\huangcheng\database\admin.mdb"
connstr="provider=microsoft.jet.oledb.4.0;data source="&dbpath
conn.open connstr
conn.execute sql1
conn.close
set conn=nothing
response.redirect "gonggao.asp"
%>
请教各位高手,为什么上面的update语句不起作用啊,当我把"&id&"改成特定的数字时能更新,还有一个问题就是sql语句中where子句中可不可以把自动编号的字段作为查询条件?

楼上说的对哦,ID是自动编号,是数字
应该用sql1="update gonggao set gonggaotext='"&gonggaotext&"',gonggaourl='"&gonggaourl&"' where id="&id

自动编号的字段可以作为查询条件,错误在于where id='"&id&"'" 修改为:where id="&id&""

id是数字吧
不用'" &id&"'"
直接where="&id