hello all
I hope there someone to help ,to point what mistake i have done ,thank you
the error message is
ex.Message = "Incorrect decimal value: '4000000,00' for column 'Jumlah' at row 1"

denny

My code always automatically add ",00" at the end of decimal jmldec (only if ccstr=="id-ID")

here is my code:

string ccstr=CultureInfo.CurrentCulture.Name;

 if (ccstr == "id-ID")
 {
 jmldec = decimal.Parse(tbjumlah.Text, CultureInfo.GetCultureInfo("id-ID"));
 }
 if (ccstr == "en-US")
 {
 jmldec = decimal.Parse(tbjumlah.Text);// there is no addition ",00"  here
 }
                
string insert = "insert into TblKwitansi(No,Nama,Jumlah)values('" + tbNo.Text + "','" + tbnama.Text +  "','" + jmldec +  "')";//but here jmldec is added automatically with ",00" 
               
 MySqlCommand cmdinsert = new MySqlCommand(insert, conn);
 conn.Open();
 int iint = cmdinsert.ExecuteNonQuery();
 conn.Close();

 if (iint == 1)
 {
 MessageBox.Show("done", "info");
 }

Edited 5 Years Ago by __avd: Added [code] tags.

int iint = cmdinsert.ExecuteNonQuery();

hmmm? , put all your code and insert into code tags

Edited 5 Years Ago by Panathinaikos22: n/a

You're trying to use a culture specific decimal format. Use a . instead as your decimal point and instead convert to the local culture format for display.

Your other option is to change the locale of the database from its default en-US setting. Instructions on how to do this can be found on the MySQL reference site, however, this means you won't be able to store it in en-US format (10.1)

Edited 5 Years Ago by Ketsuekiame: n/a

Problem is that you are trying to insert a string into a decimal field in the database. Remove the single quote (') marks from your SQL statement or learn to use Parameters

This article has been dead for over six months. Start a new discussion instead.