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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameter w/decimal data type to stored proc

Status
Not open for further replies.

YAmoah

Technical User
Nov 7, 2000
12
US
I'm getting the following error when I attempt to pass a parameter (via an ASP page) with a decimal data type to a SQL Server 2000 stored procedure:

Microsoft OLE DB Provider for SQL Server error '80004005'

The precision is invalid.


Here's my ASP code:

set cmd = server.CreateObject ("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "sp_Name"
cmd.CommandType = 4
cmd.Parameters.Append(cmd.CreateParameter ("LATITUDE",adDecimal,adParamInput,,Cdbl(vLatitude)))
cmd.Parameters.Append(cmd.CreateParameter ("LONGITUDE",adDecimal,adParamInput,,Cdbl(vLongitude)))


I've also tried:

cmd.Parameters.Append(cmd.CreateParameter ("LATITUDE",adDecimal,adParamInput,(8,4),Cdbl(vLatitude)))
cmd.Parameters.Append(cmd.CreateParameter ("LONGITUDE",adDecimal,adParamInput,(8,4),Cdbl(vLongitude)))


Here is my stored procedure code:

CREATE PROCEDURE [DBO].[sp_Name]
@LATITUDE DECIMAL(8,4),
@LONGITUDE DECIMAL(8,4)

AS

SELECT *
FROM TABLE
WHERE LONGITUDE = @LONGITUDE
AND LATITUDE = @LATITUDE


In the table:

LATITUDE DECIMAL(8,4) LENGTH = 5
LONGITUDE DECIMAL (8,4) LENGTH = 5


Has anyone encountered this problem?
 
Sounds like your passing it a number that has too many places after the decimal point (is, is more precise then the number of spaces you have defined in your paramater declarations).

Maybe try rounding the numbers to 4 places before using them?

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top