我支持旧的Classic ASP VBscript应用程序。我的运气不好是我甚至无法调试服务器中的代码。脚本编写后,我需要直接在网页上看到输出。以下代码为Throwing 500 - 网页中的内部服务器错误。你能找到这个代码出错的地方吗?提前致谢。 我在构建代码时已按照以下链接
http://www.devx.com/tips/Tip/13399
'Set Connection String to Database
sConnect = "PROVIDER=SQLOLEDB;DATA SOURCE=SCRBNGADK00XXXX;DATABASE=SMART2XXX;UID=XXXX;PWD=XXXX;"
' Establish connection.
Set oConObj = CreateObject( "ADODB.Connection" )
Set oCmdObj = CreateObject("ADODB.Command")
Set Rs1 = CreateObject( "ADODB.Recordset" )
oConObj.ConnectionString = sConnect
oConObj.Open
Set oCmdObj.ActiveConnection = oConObj
oCmdObj.commandtype=adCmdStoredProc
oCmdObj.CommandText = "date_diff"
Set objParm = oCmdObj.CreateParameter("@from", adDBTimeStamp, adParamInput,, R1("LEAVE_FROM"))
oCmdObj.Parameters.Append objParm
Set objParm = oCmdObj.CreateParameter("@To", adDBTimeStamp, adParamInput,, R1("LEAVE_TO"))
oCmdObj.Parameters.Append objParm
Set objParm = oCmdObj.CreateParameter("@companycode", adVarChar, adParamInput,200, R2("COMPANY_CODE"))
oCmdObj.Parameters.Append objParm
Set objParm = oCmdObj.CreateParameter("@locationcode", adVarChar, adParamInput,200, R2("LOCATION_CODE"))
oCmdObj.Parameters.Append objParm
Set objParm = oCmdObj.CreateParameter("@hol", adInteger, adParamOutput)
oCmdObj.Parameters.Append objParm
set Rs1 = oCmdObj.Execute
OutPut = oCmdObj.Parameters("@hol")
If Not IsNull(OutPut) Then
wscript.echo "Result :" & OutPut
End If
Set Rs1 = Nothing
Set oConObj = Nothing
Set oCmdObj = Nothing
答案 0 :(得分:1)
对此的正确答案是turn on detailed error messages(然后确保您的浏览器不会 eat 以“友好”的名义隐藏所述详细错误消息)。但有时你真的无法控制服务器,不能做任何事情。你完全搞砸了吗?嗯,不完全是。
您可以通过On Error Resume Next
关闭错误处理,然后通过Response.Write
和Response.End
手动执行代码。
On Error Resume Next
'Set Connection String to Database
sConnect = "PROVIDER=SQLOLEDB;DATA SOURCE=SCRBNGADK00XXXX;DATABASE=SMART2XXX;UID=XXXX;PWD=XXXX;"
' Establish connection.
Set oConObj = CreateObject("ADODB.Connection")
If err.Number <> 0 Then
Response.Write "Error creating connection"
Response.End
End If
Set oCmdObj = CreateObject("ADODB.Command")
If err.Number <> 0 Then
Response.Write "Error creating command object"
Response.End
End If
Set Rs1 = CreateObject("ADODB.Recordset")
If err.Number <> 0 Then
Response.Write "Error creating recordset object"
Response.End
End If
'etc., etc., etc.
实际上,您可能只会在怀疑导致问题的行之后进行错误检查,而不是添加几十个If err.number...
部分,您可以只有一个这样的部分让您继续向下移动直到找到错误。