PC Review


Reply
Thread Tools Rate Thread

Converting text to "money" datatype for dbase insertion

 
 
Chumley the Walrus
Guest
Posts: n/a
 
      28th Jul 2004
I'm trying to insert a value into sql dbase, the value "amount" is a
money datatype (currency). Below is the parameter for the "amount"
value:

cmd.Parameters.Add(New SQLParameter("@amount", frmamount.text))

....and how I am grabbing the "amount" from the textbox control:

<asp:textbox id="frmamount" class="inputBox-gr" runat="server" />

....but I need to do something extra with the SQL Parameter (in classic
asp, something like a CCur or CInt function did the trick).

????
chumley
 
Reply With Quote
 
 
 
 
Ben Lucas
Guest
Posts: n/a
 
      28th Jul 2004
You will need to use Convert.ToDecimal() method to change the text to a
decimal type. The code would look like:

cmd.Parameters.Add(New SQLParameter("@amount",
Convert.ToDecimal(frmamount.text)))

Of course, you will want to validate the user's input to make sure that is
valid and can be converted to the decimal type.

Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Chumley the Walrus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to insert a value into sql dbase, the value "amount" is a
> money datatype (currency). Below is the parameter for the "amount"
> value:
>
> cmd.Parameters.Add(New SQLParameter("@amount", frmamount.text))
>
> ...and how I am grabbing the "amount" from the textbox control:
>
> <asp:textbox id="frmamount" class="inputBox-gr" runat="server" />
>
> ...but I need to do something extra with the SQL Parameter (in classic
> asp, something like a CCur or CInt function did the trick).
>
> ????
> chumley



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Text to Number by formula (Opposite to Text("000",A1) ) Adam Microsoft Excel Discussion 3 10th Nov 2009 10:09 AM
Converting SQL Server "money" datatype to double???? Randy Smith Microsoft ASP .NET 2 18th Apr 2007 08:24 PM
Syntax error - =IIf(text Like "0?", "", text) --- =IIf([text] = "0?", Null, "Some Caption Text") Ixak Microsoft Access Reports 8 15th Dec 2006 07:58 AM
Re: macro for converting number stored as "text" (or preceeded with ') to "number" formatting markx Microsoft Excel Programming 1 30th Jun 2006 12:14 PM
macro for converting number stored as "text" (or preceeded with ') to "number" formatting markx Microsoft Excel Programming 1 23rd Jun 2006 03:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:43 AM.