hobster
asked on
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 .Connectio n")
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_renewa l_total", adInteger, adParamOutput)
cmdCount.Execute
renew_total = cmdCount.Parameters("out_r enewal_tot al")
Set cmdCount = Nothing
Response.Write "total: " & renew_total & "<BR>"
End Sub
%>
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
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
cmdCount.CommandText = "sp_count2"
cmdCount.ActiveConnection = con
cmdCount.CommandType = adCmdStoredProc
cmdCount.Parameters.Append
cmdCount.Execute
renew_total = cmdCount.Parameters("out_r
Set cmdCount = Nothing
Response.Write "total: " & renew_total & "<BR>"
End Sub
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.