Connecting Tech Pros Worldwide Forums | Help | Site Map

Converting text to "money" datatype for dbase insertion

Chumley the Walrus
Guest
 
Posts: n/a
#1: Jul 21 '05
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
Ben Lucas
Guest
 
Posts: n/a
#2: Jul 21 '05

re: Converting text to "money" datatype for dbase insertion


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" <springb2k@yahoo.com> wrote in message
news:1ef65641.0407280809.48883e8e@posting.google.c om...[color=blue]
> 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[/color]


Closed Thread


Similar .NET Framework bytes