Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 June 4th, 2003, 06:58 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default I'm having money problems...

Greetings all,

I'm new to all this, lots of mainframe, but I have to make a prototype of a legacy system I worked on and I have a bunch of WROX books to go on.

Using ASP to present the info to the user I have an INPUT field that will be used to display and update a price, defined as a decimal(7,2) in a SQL Server 2000 database.

When I create the parameter to pass to the stored procedure, I have used

curPrice = CDBL(TRIM(request("txtPrice"))) and then create the parameter to pass to the stored procedure using the variable:

cmdParts.Parameters.Append cmdParts.CreateParameter ("@PRICE", addecimal, adParamInput, , curPrice)

I also tried it like this:

cmdParts.Parameters.Append cmdParts.CreateParameter ("@PRICE", addecimal, adParamInput, , CDbl(Trim(request("txtPrice"))))

I build the rest of the parameters and call the stored procedure.

The stored procedure has the parameter defined as

REATE PROCEDURE ADD_ITEM_DETAIL
(@ITEMSEQ Int
,@ITEMDETAILDESC varchar(50)
,@PRICE decimal(7,2)
,@REQUIRED char(01)
,@ACTIVE char(01)
)

and the field is defined in the database as a decimal(7,2)

And I get this....

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
/CE/Maintenance/Plans/UpdatePlanCodeInfo.asp, line 93


If removed all references to the 'price' and I can add rows without a problem (price is nullable)

So... how do you get a price (7.25) from the HTML to the stored procedure and get it updated? Somewhere on the way it appears I am encountering a data type conversion problem of some kind.

I've tried to redefine the field as Money vs. decimal.

Regards.

Mr. Federalist
 
Old June 4th, 2003, 10:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

So you are sending a string to the database and expect it to magically change it into a Decimil? You are going to need to convert it explicity



Hal Levy
Daddyshome, LLC
 
Old June 5th, 2003, 12:15 PM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tsbarnes
Default

mr_federalist,

   Why don't you store it in the db as a Numeric value and then do all your conversion when you display it?

FormatCurrency(NumericValue) etc..

tsbarnes
 
Old June 9th, 2003, 08:27 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I understand there is no magic here so that was the purpose of the CDbl(Trim(request("txtPrice"))) code. To take the string value from the form, remove leading and trailing spaces and to convert it to a decimal value.

Quote:
quote:Originally posted by Hal Levy
 So you are sending a string to the database and expect it to magically change it into a Decimil? You are going to need to convert it explicity



Hal Levy
Daddyshome, LLC
 
Old June 9th, 2003, 08:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Quote:
quote:Originally posted by mr_federalist
 Well, I understand there is no magic here so that was the purpose of the CDbl(Trim(request("txtPrice"))) code. To take the string value from the form, remove leading and trailing spaces and to convert it to a decimal value.
That converts it to a double- which isn't a decimal.. It's a double. Yes I know it's a long decimal, but I'd want to first change my code to do the proper conversion and see what happens.

Code:
ctype(toconvert,decimal)
will convert to a decimal


Hal Levy
Daddyshome, LLC





Similar Threads
Thread Thread Starter Forum Replies Last Post
make some money! pipeisawesome C++ Programming 4 February 2nd, 2007 11:11 AM
Help even for money shemeri XSLT 1 August 28th, 2005 12:10 PM
How to change the length of "Money" hlchuah77 SQL Server 2000 4 November 16th, 2004 08:31 AM
Money Format surendran Javascript 0 March 30th, 2004 02:35 AM
This book is a waste of money tim2ok BOOK: ASP.NET Website Programming Problem-Design-Solution 2 October 22nd, 2003 11:13 AM





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