Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert textbox to converting to insert to sql database

Posted on 2003-11-04
2
Medium Priority
?
467 Views
Last Modified: 2007-12-19
Hi there.  I have a database table with a field type of money.  When I query the database and display the information in a text box I do the following to format the data correctly.

Note the name of the textbox is AvgRevenue
AvgRevenue.Text = ( (decimal)productDR["AvgRevenue"] ).ToString("C");

This works well when I receive the information from the database, but blows up when I go to insert it back to the database.  I insert back to my database with a method that looks like this.

AddProduct (string productName, decimal AvgRevenue)

What is the best way for me to convert the AvgRevenue textbox to a decimal ?  Also, what about other datatypes.  I am sure to run into similar problems with DateTime.

Thanks
0
Comment
Question by:mdaymond
  • 2
2 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 750 total points
ID: 9681581
AddProduct("Car", Decimal.Parse(AvgRevenue.Text));

Most types have a Parse function that allows them to parse their type out of a string.

DateTime Purchased = DateTime.Parse(PurchaseDate.Text);
int Counter = Int32.Parse(Quantity.Text);
0
 
LVL 15

Expert Comment

by:SRigney
ID: 9682757
Thanks for grading the question so quickly.

What did you not like about the answer that it was only given a B?
I answer questions because I enjoy it and if there's something else that you didn't get answered then let me know and I'll try my best.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question