Solved

Convert textbox to converting to insert to sql database

Posted on 2003-11-04
2
461 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 250 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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