Henry
Henry

Reputation: 11

From textbox to decimal value then into access database in c#

I'm reading a decimal value from textbox1 and need to insert it to an decimal field in my database.

I having a trouble with "," and "." so first I'm replacing ","s with "." But unfortunately If I enter 1.34 in textbox, it becomes 134.00 in db.

string text = textBox1.Text;
text = text.Replace(",", ".");
decimal total = decimal.Parse(text);

how can I solve this issue?

Upvotes: 1

Views: 3325

Answers (1)

Rubens Farias
Rubens Farias

Reputation: 57956

What about:

CultureInfo en_us = new CultureInfo("en-US");
decimal value = Decimal.Parse(text, en_us);

Upvotes: 1

Related Questions