Using IIS 7.5 with SQL Server 2008. Have some screens exposed to clients after login. Was originally tasked with finding out why some fields did not show. Fixed that. But also found that some pages include SQL strings that include stored procedure and adding parameters that are not usually provided by users, but could be potentially exploited. So as secondary task, have attempted to parameterize the query. What I am finding is that as soon as I attempt to assign values to any properties of the command object, it causes the server to return a 500 error. I don't see anything in the logs, but I think that's because I haven't found the right logs.
Here is the test code I'm trying:
<%
Dim strCnxn
strCnxn = "DSN=myDSN"
Dim objConnection
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Mode = acModeRead
objConnection.Open strCnxn
Dim cmd
cmd = Server.CreateObject("ADODB.Command")
Dim rsPmts
Set rsPmts = CreateObject("ADODB.Recordset")
'cmd.ActiveConnection = objConnection
'cmd.CommandType = adCmdStoredProc
'cmd.CommandType = 4
'cmd.CommandText = "spNewPayments"
'cmd.Parameters.Refresh
'cmd.Parameters.Append .CreateParameter("@claim_id", adInteger, adParamInput, , 162611)
'rsPmts.Open cmd, , adOpenForwardOnly, adLockReadOnly
'rsPmts.Close
Set rsPmts = Nothing
Set objConnection = Nothing
Set cmd = Nothing
%>
The commented code is where problems start to occur. Originally I had this set up as With cmd
structure, but tried changing that to see exactly where the problem occurs. It fails any time I attempt to assign anything to cmd.propertyname. So, above, if I try to comment out one of those lines, it immediately gives 500 error. At first, I thought it was because I wasn't properly using the .CreateParameter
except it doesn't seem to be just that line, but when I set any of the properties on the cmd object.
I've never done this in VBScript, and a similar structure in VBA for Access runs fine (although I'm also currently trying to debug why it thinks that I'm not providing the correct number of parameters to the stored procedure, but I think I have two confounding errors going on here.)