ASP调用存储过程出错看看,代码简单

vick 2005-12-05 12:12:38
<!--#include file="conn.asp"-->
<!--#include file="function.inc"-->
<%
dim KeyPickCounts,TakeBillCounts,LoadBillCounts,OpenAccountCounts,DelAccountCounts,SearchCounts,ClearCardPassword,ExtendCardTime,PrintCounts
Dim objCmd
set objCmd = Server.CreateObject("ADODB.Command")

objCmd.ActiveConnection = conn
objCmd.CommandText = "sp_getBusinessInfo"
objCmd.CommandType = adCmdStoredProc

objCmd.CreateParameter("@OrgID", adChar, adParamInput,6,"000001")
objCmd.Parameters.Append.CreateParameter("@Style", adInteger, adParamInput, , 0)

objCmd.Parameters.Append.CreateParameter("@ReportDate1", adVarChar, adParamInput, 50,"")
objCmd.Parameters.Append .CreateParameter("@ReportDate1", adVarChar, adParamInput, 50,"20100101")

objCmd.Parameters.Append .CreateParameter("@KeyPickCounts", adInteger, adParamOutput, , 0)
objCmd.Parameters.Append .CreateParameter("@TakeBillCounts", adInteger, adParamOutput, , 0)
objCmd.Parameters.Append .CreateParameter("@LoadBillCounts", adInteger, adParamOutput, , 0)
objCmd.Parameters.Append .CreateParameter("@OpenAccountCounts", adInteger, adParamOutput, , 0)
objCmd.Parameters.Append .CreateParameter("@DelAccountCounts", adInteger, adParamOutput, , 0)
objCmd.Parameters.Append .CreateParameter("@SearchCounts", adInteger, adParamOutput, , 0)
objCmd.Parameters.Append .CreateParameter("@ClearCardPassword", adInteger, adParamOutput, , 0)
objCmd.Parameters.Append .CreateParameter("@ExtendCardTime", adInteger, adParamOutput, , 0)
objCmd.Parameters.Append .CreateParameter("@PrintCounts", adInteger, adParamOutput, , 0)

Execute the function
objCmd.Execute, , adExecuteNoRecords
KeyPickCounts = objCmd.Parameters("@KeyPickCounts")
TakeBillCounts = objCmd.Parameters("@TakeBillCounts")
LoadBillCounts = objCmd.Parameters("@LoadBillCounts")
OpenAccountCounts = objCmd.Parameters("@OpenAccountCounts")
DelAccountCounts = objCmd.Parameters("@DelAccountCounts")
SearchCounts = objCmd.Parameters("@SearchCounts")
ClearCardPassword = objCmd.Parameters("@ClearCardPassword")
ExtendCardTime = objCmd.Parameters("@ExtendCardTime")
PrintCounts = objCmd.Parameters("@PrintCounts")

%>
存储过程很简单:
CREATE PROCEDURE [dbo].[sp_getBusinessInfo]
@OrgID char(6)='',
@Style int = 0,
@ReportDate1 char(8)='',
@ReportDate2 char(8)='20100101',
@KeyPickCounts int = 0 output,
@TakeBillCounts int = 0 output,
@LoadBillCounts int = 0 output,
@OpenAccountCounts int = 0 output,
@DelAccountCounts int = 0 output,
@SearchCounts int = 0 output,
@ClearCardPassword int = 0 output,
@ExtendCardTime int = 0 output,
@PrintCounts int = 0 output

AS

BEGIN
if @Style=1
Begin
SELECT @KeyPickCounts = count(*) from KeyPickCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
SELECT @TakeBillCounts = count(*) from TakeBillCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
SELECT @LoadBillCounts = count(*) from LoadBillCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
SELECT @OpenAccountCounts = count(*) from OpenAccountCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
SELECT @DelAccountCounts = count(*) from DelAccountCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
SELECT @SearchCounts = count(*) from SearchCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
SELECT @ClearCardPassword = count(*) from ClearCardPassword where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
SELECT @ExtendCardTime = count(*) from ExtendCardTime where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
SELECT @PrintCounts = count(*) from PrintCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2
End
else
Begin
SELECT @KeyPickCounts = count(*) from KeyPickCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
SELECT @TakeBillCounts = count(*) from TakeBillCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
SELECT @LoadBillCounts = count(*) from LoadBillCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
SELECT @OpenAccountCounts = count(*) from OpenAccountCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
SELECT @DelAccountCounts = count(*) from DelAccountCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
SELECT @SearchCounts = count(*) from SearchCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
SELECT @ClearCardPassword = count(*) from ClearCardPassword where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
SELECT @ExtendCardTime = count(*) from ExtendCardTime where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
SELECT @PrintCounts = count(*) from PrintCounts where ReportDate>=@ReportDate1 AND ReportDate<=@ReportDate2 AND OrgID=@OrgID
End
END
GO

出错:

ADODB.Command 错误 '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/inspect/BusinessInfo.asp,行85
就是:objCmd.CommandType = adCmdStoredProc通不过,改成4可以通过,但下面的就不行,同样错误

...全文
116 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
vick 2005-12-07
  • 打赏
  • 举报
回复
谢谢各位!
chjpeng 2005-12-05
  • 打赏
  • 举报
回复
没有包含adovbs.inc文件
chinastorm 2005-12-05
  • 打赏
  • 举报
回复
我也出项过这样的问题,加个adovbs.inc就好了!
showlin 2005-12-05
  • 打赏
  • 举报
回复
1楼正解
adCmdStoredProc是在adovbs.inc里定义的一个常量,值就是4,表示command对象参数是一个存储过程

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧