Javascript SQL命令将不会在ASP web app中执行
我正在使用ASP classic制作一个web应用程序,并尝试更新Oracle数据库中的一些值。这是我到目前为止所拥有的Javascript SQL命令将不会在ASP web app中执行,javascript,oracle,http,asp-classic,Javascript,Oracle,Http,Asp Classic,我正在使用ASP classic制作一个web应用程序,并尝试更新Oracle数据库中的一些值。这是我到目前为止所拥有的 <script> function getUpdateHTML() { var lockoutcheck; if (document.getElementById("cellRollLockoutYN").checked) { lockoutcheck = "'Y'"; } else {
<script>
function getUpdateHTML()
{
var lockoutcheck;
if (document.getElementById("cellRollLockoutYN").checked)
{
lockoutcheck = "'Y'";
}
else
{
lockoutcheck = "'N'";
}
var updatestring = "RollInventoryViewDev.asp?updatelockout=";
updatestring = updatestring + lockoutcheck + "&updatepatterndepth=";
updatestring = updatestring + document.getElementById("cellProductPatternDepthAvg").value + "&";
updatestring = updatestring + "action=update&sort=roll_id&sortdir=<%=intSortDir%>&id=<%=intRollID%>&iddt=<%=StrRollIdDt%>&seqnum=<%=intRollSeqNum%>&findesc=<%=strRollFinishDescription%>&fincd=<%=strRollFinishCD%>&diam=<%=dblRollDiameter%>&crown=<%=dblRollCrown%>&crownaim=<%=dblRollCrownAim%>&prosrough=<%=intRollProsRoughness%>&peaksrough=<%=intRollPeaksRoughness%>&hardness=<%=intRollHardness%>&metalcd=<%=strRollMetalCD%>&rolltype=<%=strRollType%>&lockout=<%=chrRollLockoutYN%>&depthavg=<%=dblProductPatternDepthAvg%>";
<!--alert("Attempting to Update Record with Lockout: " + lockoutcheck + " and Pattern Depth: " + document.getElementById("cellProductPatternDepthAvg").value);-->
window.open(updatestring,"_self")
}
</script>
<%
'If update selected, then update information
If Request.QueryString("action") = "update" Then
sqlQry = "update tp07_roll_inventory_row set roll_lockout_yn = "&chrUpdateLockout&", product_pattern_depth_avg = "&dblUpdateDepthAvg&" where roll_id = "&intRollID&""%>
<script>alert("<%=sqlQry%>");</script>
<%
' Turn error handling on. If an error is generated, our program will continue to execute and
' the error code will be stored in Err.number.
'On Error Resume Next
' Execute SQL code
Set RS = dbConn.Execute(sqlQry, RowsAffected)
' If an error occured then construct an error message to display to the user
If err<>0 then
message="Unable to Perform Update: "
for each objErr in dbConn.Errors
message = message & objErr.Description & "<br>"
next
' Set message color to red to indicate failure
messageColor = "#DD2222"
' If there was no error then generate a "success" message to display to the user
Else
message="Update Successful: " & rowsAffected & " row(s) updated."
' Set message color to green to indicate success
messageColor = "#22DD22"
End If
Response.write(message)
End If
%>
将您的代码更改为此,然后查看是否打印出任何错误:我已在消息中添加了
错误说明
<%
' Turn error handling on. If an error is generated, our program will continue to execute and
' the error code will be stored in Err.number.
On Error Resume Next
' Execute SQL code
Call dbConnect()
Set result = dbConn.Execute(sqlQry, rowsAffected)
' If an error occured then construct an error message to display to the user
If err.Number <> 0 then
message="Unable to Perform Update: "
'get the error description from err object
message = message & Err.Description & "<br>"
'get errors, if any, from connection object
for each objErr in dbConn.Errors
message = message & objErr.Description & "<br>"
next
' Set message color to red to indicate failure
messageColor = "#DD2222"
' If there was no error then generate a "success" message to display to the user
Else
message="Update Succssfull: " & rowsAffected & " row(s) updated."
' Set message color to green to indicate success
messageColor = "#22DD22"
End If
Call dbDisconnect()
Response.Write(message)
End If
%>
您使用的是什么数据库驱动程序?它是否生成错误集合?此代码易受sql注入攻击。这简直是乞求被黑客攻击。删除出错,下一步继续
,暂时查看是否有错误。@searchandreq:我做到了,现在我得到了HTTP 500error@JoelCoehoorn我将如何修复此问题?无法执行更新:需要对象dbconn是什么?如果这是一个连接字符串,您必须首先使用它选择一个连接对象,我想这可能是因为dbConn还不存在。我刚刚意识到我的数据库连接代码直到更新代码之后才出现(出于一些愚蠢的原因)。我将连接代码移到了更新代码之上,现在只要单击update,它就会挂起。dbConn是连接对象。我只是试着将更新代码移到程序的底部(这样它在所有HTML执行之后才会执行),现在我得到了所需的对象againit不管您是否将asp代码放在HTML之前,服务器端代码都会首先执行。唯一的问题是,在执行execute
<%
' Turn error handling on. If an error is generated, our program will continue to execute and
' the error code will be stored in Err.number.
On Error Resume Next
' Execute SQL code
Call dbConnect()
Set result = dbConn.Execute(sqlQry, rowsAffected)
' If an error occured then construct an error message to display to the user
If err.Number <> 0 then
message="Unable to Perform Update: "
'get the error description from err object
message = message & Err.Description & "<br>"
'get errors, if any, from connection object
for each objErr in dbConn.Errors
message = message & objErr.Description & "<br>"
next
' Set message color to red to indicate failure
messageColor = "#DD2222"
' If there was no error then generate a "success" message to display to the user
Else
message="Update Succssfull: " & rowsAffected & " row(s) updated."
' Set message color to green to indicate success
messageColor = "#22DD22"
End If
Call dbDisconnect()
Response.Write(message)
End If
%>