 |
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

April 26th, 2004, 10:58 AM
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Error converting data type varchar to float.
Hi,
I am receiving this error when trying to pass a value from ASP to SQL, below is the SP and a snippet from the update code from the ASP page, any ideas on how to rectifiy this. I have used a similar syntax in an add SP and that works fine, the supp_rent_val2 and usr_rent_val2 are the two values im passing in:
======SP========
CREATE PROCEDURE dbo.cnms_rentals_update
@RENT_TYPE_SUPP FLOAT= NULL,
@RENTAL_SUPP VARCHAR(1)=NULL,
@RENT_TYPE VARCHAR(1)= NULL,
@RENTAL FLOAT= NULL,
@START_DATE DATETIME= NULL,
@END_DATE DATETIME = NULL,
@ROW_ID INT= NULL
AS
BEGIN
UPDATE RENTAL SET
RENT_TYPE_SUPP = convert(float,@RENT_TYPE_SUPP),
RENTAL_SUPP = @RENTAL_SUPP,
RENT_TYPE = @RENT_TYPE,
RENTAL = convert(float,@RENTAL),
START_DATE= @START_DATE,
END_DATE = @END_DATE
WHERE
row_id = @ROW_ID
END
GO
==========ASP=========
szSQL="EXEC dbo.cnms_rentals_update"
if request("supp_rent_val2")<> "" then
szSQL = szSQL & ", @RENT_TYPE_SUPP = " & request("supp_rent_val2")
end if
if request("supp_rent_per2")<> "" then
szSQL = szSQL & ", @RENTAL_SUPP = '" & request("supp_rent_per2")& "'"
end if
if request("usr_rent_val2")<> "" then
szSQL = szSQL & ", @RENTAL = " & request("usr_rent_val2")
end if
===================================
Thanks in advance
Peter
|

April 26th, 2004, 11:11 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Instead of executing it, for testing purposes in your ASP, write the szSQL string to the browser and see what it contains. If you post that too, it may help find the problem.
|

April 26th, 2004, 11:13 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
what value does these two variables contain?
supp_rent_val2 and usr_rent_val2
Print that out and see if you are passing valid data, before you pass it on to SP.
-Vijay G
|

April 26th, 2004, 11:23 AM
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This is the results:
EXEC dbo.cnms_rentals_update @RENT_TYPE_SUPP = 'D', @RENTAL_SUPP = 0.479124, @RENTAL = 0.48, @RENT_TYPE = 'D', @START_DATE= '1/May/2004', @ROW_ID = '60'
@RENTAL_SUPP and @RENTAL are the two values in question
|

April 26th, 2004, 12:00 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
For RENT_TYPE_SUPP you have defined as: @RENT_TYPE_SUPP FLOAT= NULL,
but you pass in: @RENT_TYPE_SUPP = 'D'
That isn't going to work. Also, you have single quotes around the @ROW_ID entry when it's an int. You may want to remove that.
Brian
|

April 27th, 2004, 02:56 AM
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Brian,
You were correct, I had been looking at it to long OI didn't see it.
Many thanks
Peter
|
|
 |