Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 26th, 2004, 11:58 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
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


Reply With Quote
  #2 (permalink)  
Old April 26th, 2004, 12:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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.
Reply With Quote
  #3 (permalink)  
Old April 26th, 2004, 12:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #4 (permalink)  
Old April 26th, 2004, 12:23 PM
Authorized User
 
Join Date: Nov 2003
Location: , , .
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
Reply With Quote
  #5 (permalink)  
Old April 26th, 2004, 01:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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
Reply With Quote
  #6 (permalink)  
Old April 27th, 2004, 03:56 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error converting data type varchar to int. - SQL baysaa SQL Server ASP 1 March 17th, 2008 12:56 AM
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 10:59 AM
Error converting data type nvarchar to datetime. Andreas ADO.NET 2 August 18th, 2004 04:03 AM



All times are GMT -4. The time now is 08:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.