Stored procedure problem!

This should be an easy one!

I have a table called "renewal", which has a field called "owing" of type varchar(10). The owing field contains only numbers (some of them have decimals). I created a stored procedure called sp_count2 which finds the sum of the "owing" field. The stored procedure works.

The problem is when I call the stored procedure from a web page, I can't retrieve the sum if I set the total variable to type float. If I set it to adInteger, then it returns an integer.

If I set it to adFloat or adNumeric, I get this error:

ADODB.Parameters error '800a0e7c'
The application has improperly defined a Parameter object.

Here's the stored procedure:

CREATE PROCEDURE sp_count2
   @out_renewal_total float OUTPUT
AS
declare @q_renewal_total float

Select @q_renewal_total = Sum(Convert(float(10,2), owing))
From renewal

select @out_renewal_total = @q_renewal_total
GO

Here's the ASP page:

<%
Dim renewal_total

Call get_count()

Function get_count()

   Dim conn
      
   set conn = Server.CreateObject("ADODB.Connection")
   conn.Open "dsn"

   ' find total counts for this year
   Call calc_count(conn, renewal_total)

   conn.Close
   Set conn = Nothing

End Function


' Calculate total revenue
Sub calc_count(con, renew_total)

   Dim cmdCount
      
   Set cmdCount = Server.CreateObject("ADODB.Command")
   cmdCount.CommandText = "sp_count2"

   cmdCount.ActiveConnection = con
   cmdCount.CommandType = adCmdStoredProc

   cmdCount.Parameters.Append    cmdCount.CreateParameter("out_renewal_total", adInteger, adParamOutput)

   cmdCount.Execute

   renew_total = cmdCount.Parameters("out_renewal_total")
      
   Set cmdCount = Nothing

   Response.Write "total: " & renew_total & "<BR>"

End Sub      

%>
LVL 2
hobsterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mmipsCommented:
Try adSingle...instead

adSingle 4 Indicates aA single-precision floating- point value (DBTYPE_R4).

adNumeric 131 Indicates aAn exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).

adFloat doesn't exist

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.