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可以通过,但下面的就不行,同样错误