对于经典ASP,我有点绿,所以我提前道歉。
我有一个带有表单的asp页面,其中包含了pc设备的详细信息。然后将其添加到SQL数据库中。有魅力......
然而,在我们可以更改任何细节的视图页面上,当我点击"保存更改"按钮我收到错误。
' ='
附近的语法不正确
这就是我所拥有的:
<!-- #include file="Tauthenticate.asp" -->
<!--#include file="database.asp"-->
<%
pcname=request.form("T1")
pctype=request.form("T2")
pccpu=request.form("T3")
pcram=request.form("T4")
pcmake=request.form("T5")
pcmodel=request.form("T5b")
pcdate=request.form("T6")
graphics=request.form("T7")
notes=request.form("T8")
tag=request.form("T9")
cd_dvd=request.form("T10")
sqlq = "UPDATE PC set PC_Name='" & pcname & "', Type='" & pctype & "', CPU='" & pccpu & "', RAM='" & pcram & "', Make='" & pcmake & "', Model='" & pcmodel & "', Date='" & pcdate & "', Graphics='" & graphics & "', Notes='" & notes & "', Service_Tag='" & tag & "', CD_DVD='" & cd_dvd & "' where PC_ID=" & pcid
response.write(sqlq)
conn.execute(sqlq)
Response.Redirect("../PCs/PCView.asp?pc=" & pcid)
%>
经过快速测试后,我得到了这个结果
UPDATE PC set PC_Name =&#39; LRW9999&#39;,Type =&#39; Desktop PC&#39;,CPU =&#39; blah blah&#39;,RAM =&#39; 5555&#39 ;,Make =&#39; blah blah&#39;,Model =&#39; doo doo&#39;,Date =&#39; 09/02 / 16&#39;,Graphics =&#39; blah blah&# 39;,Notes =&#39;仅测试&#39;,Service_Tag =&#39; gyudsgysdgsgghfs&#39;,CD_DVD =&#39; 9999&#39;其中PC_ID =
用于SQL Server的Microsoft OLE DB提供程序错误&#39; 80040e14&#39;
&#39; =&#39;附近的语法不正确。
/PCs /SaveChangesnew.asp,第28行
我哪里错了?我似乎无法看到树木的木材,我需要新鲜的眼睛来帮助我。
答案 0 :(得分:0)
将您的sqlquery更新为以下内容:
sqlq = "UPDATE PC set PC_Name='" & pcname & "', Type='" & pctype & "', CPU='" & pccpu & "', RAM='" & pcram & "', Make='" & pcmake & "', Model='" & pcmodel & "', Date='" & pcdate & "', Graphics='" & graphics & "', Notes='" & notes & "', Service_Tag='" & tag & "', CD_DVD='" & cd_dvd & "' where PC_ID='" & pcid &"'"