how to convert string to decimal
-
hi frns below is the code snippet i used in my proj actually i'll be giving some decimal value in the textbox input. I want to insert that textbox value into my database table. In the database i used that particular column as datatype decimal with precision 5 and scale 2.
SqlParameter pErrorPoints = new SqlParameter("@ErrorPoints", SqlDbType.Decimal); pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
if anybody knows the answer please do let me know regards sunilwise:) -
hi frns below is the code snippet i used in my proj actually i'll be giving some decimal value in the textbox input. I want to insert that textbox value into my database table. In the database i used that particular column as datatype decimal with precision 5 and scale 2.
SqlParameter pErrorPoints = new SqlParameter("@ErrorPoints", SqlDbType.Decimal); pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
if anybody knows the answer please do let me know regards sunilwise:)sunilwise wrote:
pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
Hi, these are two ways to do that.
Convert.ToDecimal(txtPoints.Text.Trim()) or Decimal.Parse(txtPoints.Text.Trim())
Thanks, Sun Rays Rate this post if you like answer. My Articles
-
hi frns below is the code snippet i used in my proj actually i'll be giving some decimal value in the textbox input. I want to insert that textbox value into my database table. In the database i used that particular column as datatype decimal with precision 5 and scale 2.
SqlParameter pErrorPoints = new SqlParameter("@ErrorPoints", SqlDbType.Decimal); pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
if anybody knows the answer please do let me know regards sunilwise:)sunilwise wrote:
decimal.Parse(txtPoints.Text.Trim());
What is your question ? I see you are doing a conversion here.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
hi frns below is the code snippet i used in my proj actually i'll be giving some decimal value in the textbox input. I want to insert that textbox value into my database table. In the database i used that particular column as datatype decimal with precision 5 and scale 2.
SqlParameter pErrorPoints = new SqlParameter("@ErrorPoints", SqlDbType.Decimal); pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
if anybody knows the answer please do let me know regards sunilwise:)You don't actually need to convert the value to a decimal to use it in a SqlParameter.Value. The conversion is useful to prove that it is a decimal, but isn't actually needed by the system.
Deja View - the feeling that you've seen this post before.
-
hi frns below is the code snippet i used in my proj actually i'll be giving some decimal value in the textbox input. I want to insert that textbox value into my database table. In the database i used that particular column as datatype decimal with precision 5 and scale 2.
SqlParameter pErrorPoints = new SqlParameter("@ErrorPoints", SqlDbType.Decimal); pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
if anybody knows the answer please do let me know regards sunilwise:) -
hi frns below is the code snippet i used in my proj actually i'll be giving some decimal value in the textbox input. I want to insert that textbox value into my database table. In the database i used that particular column as datatype decimal with precision 5 and scale 2.
SqlParameter pErrorPoints = new SqlParameter("@ErrorPoints", SqlDbType.Decimal); pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
if anybody knows the answer please do let me know regards sunilwise:)I don't see your problem, but you can use Decimal.TryParse() to be sure that you have a decimal value in your textbox and avoid errors in your application. Hope it helps.
I will use Google before asking dumb questions
-
sunilwise wrote:
pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
Hi, these are two ways to do that.
Convert.ToDecimal(txtPoints.Text.Trim()) or Decimal.Parse(txtPoints.Text.Trim())
Thanks, Sun Rays Rate this post if you like answer. My Articles
Sun Rays wrote:
Convert.ToDecimal(txtPoints.Text.Trim()) or Decimal.Parse(txtPoints.Text.Trim())
ok i got it both are working my thanx to all those have answered my question from the bottom of my heart