VBScript使用输入参数调用存储过程

时间:2017-08-09 14:52:13

标签: sql-server vbscript ado testcomplete

我试图从VBScript代码调用SQL Server存储过程。存储过程有五个输入和一个输出参数。当我执行它时,我得到以下错误。这里有什么不妥吗?

enter image description here

将从VBScript

调用的存储过程
ALTER procedure [dbo].[QA_SPInsertOrdersOmBlotter_New]
(
    @p_acc_code char(3) ,
    @p_sec_id char(16),
    @p_iso_country char(2),
    @p_side char(4),
    @p_shares float,
    @p_location varchar(10)
    @ProgramNumber_Out int Output --blotter program_no,

)
as
begin

调用存储过程的VB脚本代码

    set cmd = CreateObject("ADODB.Command")
set rs = CreateObject ("ADODB.RecordSet")
conn.Open p_conn
cmd.ActiveConnection = conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = p_procedurename

Set fso = aqFile.OpenTextFile ("C:\OrdersFile.csv",aqFile.faRead,aqFile.ctANSI)
Dim ArrStr
Call fso.SetPosition(1,0)

While NOT fso.IsEndOfFile

ArrStr=Split(fso.ReadLine(),",")

Log.Message "Acc_Code "&ArrStr(0)
Log.Message "Sec_Id "&ArrStr(1)
Log.Message "IsoCountry "&ArrStr(2)
Log.Message "Side "&ArrStr(3)
Log.Message "Shares "&ArrStr(4)
Log.Message "Location "&ArrStr(5)

Acc_Code=aqConvert.VarToStr(ArrStr(0))
Sec_Id=aqConvert.VarToStr(ArrStr(1))
Iso_Country = aqConvert.VarToStr(ArrStr(2))
Buy_Sell= aqConvert.VarToStr(ArrStr(3))
Qty=aqConvert.VarToFloat(ArrStr(4))
Location= aqConvert.VarToStr(ArrStr(5))

cmd.Parameters.Refresh
cmd.Parameters.Append(cmd.CreateParameter("@ProgramNumber_Out",adInteger,adParamOutput)) 
cmd.Parameters.Append(cmd.CreateParameter("@p_acc_code",129,adParamInput,3,Acc_Code))
cmd.Parameters.Append(cmd.CreateParameter("@p_sec_id", 129,adParamInput,16,Sec_Id))
cmd.Parameters.Append(cmd.CreateParameter("@p_iso_country", 129,adParamInput,2,Iso_Country)) 
cmd.Parameters.Append(cmd.CreateParameter("@p_side", 129,adParamInput,4,Buy_Sell)) 
cmd.Parameters.Append(cmd.CreateParameter("@p_shares", 4, adParamInput,,Qty)) 
cmd.Parameters.Append(cmd.CreateParameter("@p_location",200,adParamInput,10,Location)) 
rs.open cmd

0 个答案:

没有答案