(ADO)--执行存储过程的错误

doghead 2002-07-23 01:50:09
后台是SQL Server数据库,存储过程为GetMainTable
在执行存储过程时出现错误,
存储过程的参数和数据库中的顺序等完全一致,他去提示没提供参数。
代码如下:
<%
dim AssociatorID
dim RegionCode
dim TradeSortCode
dim HQCode
dim AssociatorLocalNO
dim EnterpriseCode
dim AssociatorName
dim Principal
dim Address
dim Postalcode
dim Telphone
dim NetworkSortCode
dim ApplyTime
dim ServiceSortCode
dim ServiceCharacterCode
dim CertifierCode
dim ret
AssociatorID=request.cookies("AssociatorID")
set cmdGetMain=server.createobject("ADODB.Command")
cmdGetMain.activeconnection=strconn
cmdGetMain.commandtype=adcmdstoredproc
cmdGetmain.commandtext="dbo.GetMainTable"
with cmdGetMains
.parameters.append .createparameter("RETURN_VALUE",adinteger,adparamreturnvalue)
if err then
response.write "error here"
else
response.write "i am right"
end if
.parameters.append .createparameter("@AssociatorID",adinteger,adparaminput,5,AssociatorID)
.parameters.append .createparameter("@RegionCode",adtinyint,adparamoutput)
.parameters.append .createparameter("@TradeSortCode",adtinyint,adparamoutput)
.parameters.append .createparameter("@HQCode",adsmallint,adparamoutput)
.parameters.append .createparameter("@AssociatorLocalNO",adsmallint,adparamoutput)
.parameters.append .createparameter("@EnterpriseCode",adchar,adparamoutput)
.parameters.append .createparameter("@AssociatorName",adchar,adparamoutput)
.parameters.append .createparameter("@Principal",adchar,adparamoutput)
.parameters.append .createparameter("@Address",adchar,adparamoutput)
.parameters.append .createparameter("@Postalcode",adchar,adparamoutput)
.parameters.append .createparameter("@Telphone",adchar,adparamoutput)
.parameters.append .createparameter("@NetworkSortCode",adtinyint,adparamoutput)
.parameters.append .createparameter("@ApplyTime",adTimeStamp,adparamoutput)
.parameters.append .createparameter("@ServiceSortCode",adtinyint,adparamoutput)
.parameters.append .createparameter("@ServiceCharacterCode",adtinyint,adparamoutput)
.parameters.append .createparameter("@CertifierCode",adtinyint,adparamoutput)

.execute ,,adExectueNoRecodes
'在这里出错,
'---------------------------------------------------*/
'Warning The Following Error Has Occurred:
'过程 'GetMainTable' 需要参数 '@Postalcode',但未提供该参数。
'-2147217904
'Microsoft OLE DB Provider for SQL Server
'---------------------------------------------------*/
ret= .parameters("RETURN_VALUE")

if ret=1 then
RegionCode=.parameters("@RegionCode")
TradeSortCode=.parameters("@TradeSortCode")
HQCode=.parameters("@HQCode")
AssociatorLocalNO=.parameters("@AssociatorLocalNO")
EnterpriseCode=.parameters("@EnterpriseCode")
AssociatorName=.parameters("@AssociatorName")
Principal=.parameters("@Principal")
Address=.parameters("@Address")
Postalcode=.parameters("@Postalcode")
Telphone=.parameters("@Telphone")
NetworkSortCode=.parameters("@NetworkSortCode")
ApplyTime=.parameters("@ApplyTime")
ServiceSortCode=.parameters("@ServiceSortCode")
ServiceCharacterCode=.parameters("@ServiceCharacterCode")
CertifierCode=.parameters("@CertifierCode")
response.write telphone
--------------------------------------------------------------------------
创建存储过程的SQL代码如下

CREATE PROCEDURE dbo.GetMainTable
@AssociatorID int,
@RegionCode tinyint output ,
@TradeSortCode tinyint output,
@HQCode smallint output,
@AssociatorLocalNO smallint output ,
@EnterpriseCode char (10) output ,
@AssociatorName char (40) output ,
@Principal char (12) output ,
@Address char (50) output ,
@Postalcode char (6) output ,
@Telphone char (40) output ,
@NetworkSortCode tinyint output ,
@ApplyTime datetime output ,
@ServiceSortCode tinyint output ,
@ServiceCharacterCode tinyint output ,
@CertifierCode tinyint output

AS
declare @ret int;
exec @ret=VerifyPopedom @AssociatorID;//这里参数正确
if @ret=0 return 0;
select
@RegionCode=RegionCode ,
@TradeSortCode =TradeSortCode,
@HQCode =HQCode,
@AssociatorLocalNO=AssociatorLocalNO,
@EnterpriseCode=EnterpriseCode,
@AssociatorName= AssociatorName,
@Principal=Principal,
@Address=Address,
@Postalcode=Postalcode,
@Telphone =Telphone,
@NetworkSortCode =NetworkSortCode,
@ApplyTime =ApplyTime,
@ServiceSortCode =ServiceSortCode,
@ServiceCharacterCode =ServiceCharacterCode,
@CertifierCode =CertifierCode
from MainInformation
where AssociatorID=@AssociatorID;
return 1;
GO
...全文
51 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
york00 2002-07-25
  • 打赏
  • 举报
回复
输入和输出的参数都要加上长度,如果是char型的,要加上本来长度,varchar型的要加上最大长度。
doghead 2002-07-25
  • 打赏
  • 举报
回复
现在问题已解决
.parameters.append .createparamete ("@Principal",adchar,adparamoutput,6)
参数应加上长度
doghead 2002-07-23
  • 打赏
  • 举报
回复
错误信息:
3708
ADODB.Parameters
Parameter 对象被不正确地定义。提供了不一致或不完整的信息。
doghead 2002-07-23
  • 打赏
  • 举报
回复
freezwy(网络自由人) 的建议我查过了,问题没解决,
york00 2002-07-23
  • 打赏
  • 举报
回复
这个问题我也碰到了,查来查去都不知道为什么,等待答案
freezwy 2002-07-23
  • 打赏
  • 举报
回复
那是你数据库的设计问题,就是说你把POSTCODE字段设计成必填的了,你最好把这个字段设计成char(6)或者varchar(6)并且允许NULL,在客户端提交的时候尽量做完整性检查。
freezwy 2002-07-23
  • 打赏
  • 举报
回复
那是你数据库的设计问题,就是说你把POSTCODE字段设计成必填的了,你最好把这个字段设计成char(6)或者varchar(6)并且允许NULL,在客户端提交的时候尽量做完整性检查。
doghead 2002-07-23
  • 打赏
  • 举报
回复
当把存储过程的前三行注释掉时
/*( declare @ret int;
exec @ret=VerifyPopedom @AssociatorID;//这里参数正确
if @ret=0 return 0;)*/
则出现指示EnterpriseCode=.parameters("@EnterpriseCode")
参数不完整的错误,

28,390

社区成员

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

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