Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

precision is invalid error 2

Status
Not open for further replies.

shaminda

Programmer
Joined
Jun 9, 2000
Messages
170
Location
US

I am trying to execute a SQL Server 2000 stored procedure in a Visual Basic 6.0 program. I am getting the following error and don’t know how to fix it.

-2147467259 The precision is invalid

On the SQL Server the field name is RecordNum. RecordNum is a numeric size 9 with a precision of 18. Here is the code for the stored procedure

CREATE Procedure SpGetRecordNum
(
@vRecordNum numeric OUTPUT
)
As
select @vRecordNum=max(RecordNum) from RecEntry
return

GO

I am getting the error on the execute statement. Here is the code on VB side

comGetRecordNum.Parameters.Append comGetRecordNum.CreateParameter("@vRecordNum", adNumeric, adParamOutput, 9)
comGetRecordNum.Execute

How can I fix this error?
 
Try this:
Code:
comGetRecordNum.Parameters.Append comGetRecordNum.CreateParameter("@vRecordNum", adNumeric, adParamOutput, 9)
Code:
comGetRecordNum.Parameters("@vRecordNum").Precision = 3
Code:
comGetRecordNum.Execute
-dave
 
Whoops... jumped the gun there.

Should be more like this:
Code:
comGetRecordNum.Parameters("@vRecordNum").NumericScale = 2
comGetRecordNum.Parameters("@vRecordNum").Precision = 10
Looks like you're very likely returning an Integer value. Why not just declare you proc. parameter as INT, then you could go with:
Code:
comGetRecordNum.Parameters.Append cmd.CreateParameter("@vRecordNum", adInteger, adParamOutput)
-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top