存储过程 – 经典ASP – ADO执行存储过程传入​​参数

前端之家收集整理的这篇文章主要介绍了存储过程 – 经典ASP – ADO执行存储过程传入​​参数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要使用Classic ASP将参数传递给存储过程.我确实看到一些人使用Command对象而其他人没有使用它.

我的sproc params是这样的:

@RECORD_NUMBER decimal(18,0),@ErrorType nvarchar(100),@INSURANCE_CODE smallint,@CompanyId int,@INS_ID_NUM nchar(22)

然后我试着这样做:

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

(我不需要Recordset,我只是想让它发送数据)

Error:
ADODB.Recordset error ‘800a0bb9’
Arguments are of the wrong type,are out of acceptable range,or are in conflict with one another.

我尝试了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")

解决方法

您将如何操作,您将不需要创建记录集对象,因为它是一个更新存储过程:
'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
原文链接:https://www.f2er.com/aspnet/246996.html

猜你在找的asp.Net相关文章