asp调用存储过程出现错误 '800a0bb9'

create PROCEDURE dbo.sp_InsertSo
(
@cust_name varchar(120)
)
AS
BEGIN
INSERT INTO dbo.so (cust_name)
VALUES (@cust_name)

END

asp:
set cmd=server.CreateObject ("adodb.command")
set cmd.ActiveConnection=conn
cmd.CommandText="{call sp_InsertSo(?)}"
cmd.Parameters.Append cmd.CreateParameter("@cust_name",adInteger,adParamInput)
cmd("@cust_name")="999"
cmd.Execute()

ADODB.Command 错误 '800a0bb9'
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
出错行:cmd.Parameters.Append cmd.CreateParameter("@cust_name",adInteger,adParamInput)

用baidu找了半天找不到解决方法,用google搜索英文网站找到:


(a) put ``` Option Explicit

 1(b) In case if you have not included, include ADO Type library or ADOVBS.inc at the top of your page.   
 2  
 3e.g.
 4<!-- METADATA TYPE="typelib"   
 5UUID="00000205-0000-0010-8000-00AA006D2EA4"   
 6NAME="ADO 2.5 Type Library"   
 7\-->
 8于是加上:   
 9dim cmd   
10Dim adCmdSPStoredProc   
11Dim adParamReturnValue   
12Dim adParaminput   
13Dim adParamOutput   
14Dim adInteger   
15Dim iVal   
16Dim oVal   
17Dim adoField   
18Dim adVarChar 
19
20'这些值在 VB 中是预定义常量,可以直接调用,但在 VBScript 中没有预定义   
21adCmdSPStoredProc = 4   
22adParamReturnValue = 4   
23adParaminput = 1   
24adParamOutput = 2   
25adInteger = 3   
26adVarChar = 200 
27
28iVal = 5   
29oVal = 3   
30  
31  
32执行成功
Published At
Categories with Web编程
Tagged with
comments powered by Disqus