7 stored-procedures ado asp-classic
我需要使用Classic ASP将参数传递给存储过程.我确实看到一些人使用Command对象而其他人没有使用它.
我的sproc params是这样的:
@RECORD_NUMBER decimal(18,0),
@ErrorType nvarchar(100),
@INSURANCE_CODE smallint,
@CompanyId int,
@INS_ID_NUM nchar(22)
Run Code Online (Sandbox Code Playgroud)
然后我试着这样做:
Dim conn, rsSet,rsString, cmd
Dim RN,ET,IC,CI,IIN
RN = Request.Form("Record_Number")
ET = Request.Form("ErrorType")
IC = Request.Form("INSURANCE_CODE")
CI = Request.Form("CompanyID")
IIN = Request.Form("INS_ID_NUM")
set conn = server.CreateObject("adodb.connection")
set rsSet = Server.CreateObject ("ADODB.Recordset")
conn.Open Application("conMestamed_Utilities_ConnectionString")
rs_string = "apUpdateBill " & RN &",'" & ET & "'," & IC & "," & CI & ",'" & IIN & "'"
rsSet.Open rsString, conn, adOpenForwardOnly,, adCmdText
Run Code Online (Sandbox Code Playgroud)
(我不需要Recordset,我只是想让它发送数据)
错误:
ADODB.Recordset错误'800a0bb9'
参数类型错误,超出可接受范围或彼此冲突.
我已经尝试过Command的东西,我得到"精确"错误我"有"使用命令对象吗?
例如
Set cmd = Server.CreateObject("ADODB.Command")
'Set cmd.ActiveConnection = conn
'cmd.CommandText = "apUpdateBill"
'cmd.CommandType = adCmdStoredProc
'Cmd.Parameters.append Cmd.createParameter("@Record_Number", adDecimal, adParamInput, 18)
'Cmd.Parameters("@Record_Number").Precision = 0
'Cmd.Parameters("@Record_Number").value = Request.Form("Record_Number")
Run Code Online (Sandbox Code Playgroud)
med*_*eda 14
您将如何操作,您将不需要创建记录集对象,因为它是一个更新存储过程:
'Set the connection
'...............
'Set the command
DIM cmd
SET cmd = Server.CreateObject("ADODB.Command")
SET cmd.ActiveConnection = Conn
'Prepare the stored procedure
cmd.CommandText = "apUpdateBill"
cmd.CommandType = 4 'adCmdStoredProc
cmd.Parameters("@RECORD_NUMBER") = Request.Form("Record_Number")
cmd.Parameters("@ErrorType") = Request.Form("ErrorType")
cmd.Parameters("@INSURANCE_CODE") = Request.Form("INSURANCE_CODE")
cmd.Parameters("@CompanyId") = Request.Form("CompanyID")
cmd.Parameters("@INS_ID_NUM") = Request.Form("INS_ID_NUM")
'Execute the stored procedure
'This returns recordset but you dont need it
cmd.Execute
Conn.Close
SET Conn = Nothing
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20557 次 |
| 最近记录: |