Solved

Convert textbox to converting to insert to sql database

Posted on 2003-11-04
2
460 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
Input parameteres to DragOver 2 36
ASP.NET MVC -Update model when click on <li> element 29 68
pressing download button in c# 7 34
orderby list (from Json) 1 29
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled

756 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