您尝试通过存储过程更新记录时发生错误。 我得到的错误是2147217833字符串或二进制数据将被截断。
我已经在我插入的每个字段上完成了一个长度,它们应该适应数据库字段 - 即长度不大于列规范。
此刻完全感到困惑 - 可能出现此错误的任何其他原因?
谢谢,
Set objReturnParam = objComm.CreateParameter("Return",adInteger,adParamReturnValue)
Set objRiskIDParam = objComm.CreateParameter("@riskID",adBigInt,adParamInput)
Set objControlsDescriptionParam = objComm.CreateParameter("@ControlsDescription",adVarChar,adParamInput,5000)
Set objTreatmentParam = objComm.CreateParameter("@Treatment",adVarChar,adParamInput,5000)
Set objControlsParam = objComm.CreateParameter("@Controls",adVarChar,adParamInput,10)
Set objPriorityParam = objComm.CreateParameter("@Priority",adVarChar,adParamInput,6)
Set objProbabilityParam = objComm.CreateParameter("@Probability",adVarChar,adParamInput,6)
Set objImpactParam = objComm.CreateParameter("@Impact",adVarChar,adParamInput,6)
Set objScoreParam = objComm.CreateParameter("@Score",adInteger,adParamInput)
Set objReviewTimeframeParam = objComm.CreateParameter("@ReviewTimeframe",adVarChar,adParamInput,6)
Set objReviewDateParam = objComm.CreateParameter("@ReviewDate",adDate,adParamInput)
Set objDateReviewedParam = objComm.CreateParameter("@DateReviewed",adDate,adParamInput)
Set objReviewerIDParam = objComm.CreateParameter("@ReviewerID",adInteger,adParamInput)
objComm.Parameters("@riskID") = lRiskID
objComm.Parameters("@ControlsDescription") = strControlsDescription
objComm.Parameters("@Treatment") = strTreatment
objComm.Parameters("@Controls") = strControls
objComm.Parameters("@Priority") = strPriority
objComm.Parameters("@Probability") = strProbability
objComm.Parameters("@Impact") = strImpact
objComm.Parameters("@Score") = iScore
objComm.Parameters("@ReviewTimeframe") = strReviewTimeframe
objComm.Parameters("@ReviewDate") = cStr(Year(dReviewDate)) + "-" + cStr(Month(dReviewDate)) + "-" + cStr(Day(dReviewDate)) + " 00:00:00"
objComm.Parameters("@DateReviewed") = cStr(Year(Date)) + "-" + cStr(Month(Date)) + "-" + cStr(Day(Date)) + " 00:00:00"
objComm.Parameters("@ReviewerID") = Cstr(Session("UserID"))
当我输出我正在尝试更新的每个变量时,每个变量的长度为:
lRiskID:2
strControlsDescription:6
处理:6
strControls:4
strPriority:0
strProbability:1
strImpact:1
iScore:1
strReviewTimeframe:0
Reviewdate19
dateReviewed19
reviewerid2
[ID] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[CONTROLS_DESCRIPTION] [varchar](5000) COLLATE Latin1_General_CI_AS NOT NULL,
[TREATMENT] [varchar](5000) COLLATE Latin1_General_CI_AS NOT NULL,
[PRIORITY] [varchar](6) COLLATE Latin1_General_CI_AS NOT NULL,
[PROBABILITY] [varchar](6) COLLATE Latin1_General_CI_AS NOT NULL,
[IMPACT] [varchar](6) COLLATE Latin1_General_CI_AS NOT NULL,
[SCORE] [tinyint] NOT NULL,
[REVIEW_TIMEFRAME] [varchar](6) COLLATE Latin1_General_CI_AS NOT NULL,
[PROPOSED_REVIEW_DATE] [datetime] NOT NULL,
[DATE_REVIEWED] [datetime] NULL,
[REVIEWER_ID] [int] NULL,
答案 0 :(得分:2)
没有架构和代码,这很难。
随机想法:
编辑后,添加代码
@Controls在哪里?没有专栏...
对我来说,这意味着截断错误不适用于此表
答案 1 :(得分:0)
您的参数声明并不都与表的数据类型匹配。您使用的是adBigInt用于数字(使用adNumeric),adInteger用于tinyint(使用adTinyInt)。
看起来你在VB6中,而在VB6中,adDate数据类型用于Access。要更新SQL Server DB,您需要使用adDBTimeStamp作为参数数据类型。
http://www.devguru.com/Technologies/ado/quickref/command_createparameter.html