Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
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
 
Old April 26th, 2004, 10:58 AM
Authorized User
 
Join Date: Nov 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


 
Old April 26th, 2004, 11:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.
 
Old April 26th, 2004, 11:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old April 26th, 2004, 11:23 AM
Authorized User
 
Join Date: Nov 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old April 26th, 2004, 12:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
 
Old April 27th, 2004, 02:56 AM
Authorized User
 
Join Date: Nov 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Brian,

You were correct, I had been looking at it to long OI didn't see it.

Many thanks
Peter






Similar Threads
Thread Thread Starter Forum Replies Last Post
Error converting data type varchar to int. - SQL baysaa SQL Server ASP 1 March 16th, 2008 11:56 PM
Syntax error converting the varchar value... Earl Hickey ASP.NET 2.0 Basics 5 January 23rd, 2008 10:25 PM
Is maxium size of varchar data type is 8000? kawrat SQL Server 2000 7 February 5th, 2007 04:08 AM
Data type change from int to Varchar getxyz SQL Server 2000 1 April 29th, 2005 09:59 AM
Error converting data type nvarchar to datetime. Andreas ADO.NET 2 August 18th, 2004 03:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.