Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 506
  • Last Modified:

Money in sql server 2000 with ASP.net 2.0

I have a table with a field of type money.
This field gets its currency according to the culture and I format
It in a formview to show the currency symbol:
<asp:TextBox ID="AmountTextBox" runat="server" Text='<%# Bind("Amount", "{0:C}") %>'></asp:TextBox>
When I update this field I get an error:
Input string was not in a correct format.
I update with the following command:

UPDATE Candidate SET Amount = CONVERT (money, @Amount)  WHERE (Candidate_id = @Candidate_id)

If I run the following script in sql query analyzer with a value of $300 it run and update OK. If I put it into a stored procedure and run it - its OK
If I run the store procedure with open in sql query analyzer it gives an error:
Invalid value..
What is the problem here?
0
ANAT2403
Asked:
ANAT2403
  • 4
  • 3
  • 2
  • +1
1 Solution
 
Anthony PerkinsCommented:
Don't rely on the regional settings of the Server and pass a numeric value (without any currency symbol) to the UPDATE statement.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
can u check which value is giving error.. also send the exact error message..

Run profiler first, then run your application and find whether the values are passed correctly..

For example if your sp is like this

create spUpdate (@Amount money, @candidate_id int )...


and u call the ps like
exec spUpdate 300.00, 2  --- works well
exec spUpdate '3000.00',2  -- will give u the erro  
0
 
ANAT2403Author Commented:
comment to acperkins:
I don't want to pass the server the currency symbol but I have it becaule of he definition - "{0:C}"
How do I remove the currency symbol? Shall I do it in the event 'FormView1_ItemUpdated'  ?

comment to aneeshattingal:
I gave all the error messages:   INPUT STRING WAS NOT IN A CORRECT FORMAT
The problem is that I have a field which include a currency symbol and this make me problems in the update.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
Anthony PerkinsCommented:
>>but I have it becaule of he definition - "{0:C}"<<
You don't have to.  You simply have not found out how.  {0:C}  is just formatting, try submitting without.  Or even better post in a more appropriate Topic Area such as:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/
0
 
ANAT2403Author Commented:
I repeat my question:
How to remove the formatting or how to format without the currency symbol???
0
 
ANAT2403Author Commented:
I found the solution to remove the currency symbol before the updating with the parsing command:
       Decimal tempdec = Decimal.Parse(temp22.Text, System.Globalization.NumberStyles.Currency);
I I had $300 I now have 300.
0
 
ANAT2403Author Commented:
OK
0
 
Anthony PerkinsCommented:
Annie,

It is fine with me.

Anthony
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
Hi Annie,
It's fine with me too
0
 
kodiakbearCommented:
Closed, 500 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now