Today, I need to help my colleagues change an ASP page. I have several SQL queries in it. On the ASP page, I think it is cool and inefficient. So I put the query in the SQL server storage process, however, I have never used ASP stored procedures before. I will find an example on the Internet:
Function getcameraurl (Conn, cameraid)
Const adw.storedproc = & h0004
Const advarchar = 200
Const adchar = 129
Const adinteger = 3
Const adparamunknown = & h0000
Const adparaminput = & h0001
Const adparamoutput = & h0002
Const adparaminputoutput = & h0002
Const adparamreturnvalue = & h0004
Dim URL
Set release test = server. Createobject ("ADODB. Command ")
With each test
. Activeconnection = Conn
. Commandtext = "[df1500]. [DBO]. [sp_getcameraconnectioninfo]"
. Commandtype = adcmdstoredproc
'. Commandtype = ad1_text
. Parameters. append parameter test. createparameter ("return", adinteger, adparamreturnvalue, 4)
. Parameters. append. createparameter ("@ camera_id", adinteger, adparaminput, 4, cameraid)
. Parameters. append. createparameter ("@ URL", advarchar, adparamoutput, 1024)
. Execute
Url =. parameters ("@ URL"). Value
End
Set Rule test = nothing
Getcameraurl = URL
End Function
But an error is found upon execution:
The parameter type is incorrect, is not within the acceptable range, or is in conflict with other parameters.The error occurs in this line.
. Commandtype = adcmdstoredproc
ASP is rarely used. This kind of prompt is confusing. I originally thought that adstoredproc is a well-defined internal thing. Other online experts say that this thing needs to be defined by themselves. Oh, I understand. After correctionCodeAs follows:
Const adw.storedproc = & h0004
Const advarchar = 200
Const adchar = 129
Const adinteger = 3
Const adparamunknown = & h0000
Const adparaminput = & h0001
Const adparamoutput = & h0002
Const adparaminputoutput = & h0002
Const adparamreturnvalue = & h0004
Function getcameraurl (Conn, cameraid)
Const adw.storedproc = & h0004
Const advarchar = 200
Const adchar = 129
Const adinteger = 3
Const adparamunknown = & h0000
Const adparaminput = & h0001
Const adparamoutput = & h0002
Const adparaminputoutput = & h0002
Const adparamreturnvalue = & h0004
Dim URL
Set release test = server. Createobject ("ADODB. Command ")
With each test
. Activeconnection = Conn
. Commandtext = "[df1500]. [DBO]. [sp_getcameraconnectioninfo]"
. Commandtype = adcmdstoredproc
'. Commandtype = ad1_text
. Parameters. append parameter test. createparameter ("return", adinteger, adparamreturnvalue, 4)
. Parameters. append. createparameter ("@ camera_id", adinteger, adparaminput, 4, cameraid)
. Parameters. append. createparameter ("@ URL", advarchar, adparamoutput, 1024)
. Execute
Url =. parameters ("@ URL"). Value
End
Set Rule test = nothing
Getcameraurl = URL
End Function