Convert textbox to converting to insert to sql database
Posted on 2003-11-04
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.