0

I am sending parameters from c# to the mysql database. Problem is that I have decimal value in c# ( for example : 45.335 ) but when I am sending it to the mysql it keeps sending it in this format ( 45,335 ) What am I doing wrong?

    MySqlConnection con = null;
    MySqlCommand cmd = null;


    con = new MySqlConnection("server=localhost;database=data;uid=root;pwd=*****");
    con.Open();
    cmd = new MySqlCommand("insert into data values (null, ?ParName , ?Parname2);", con);
    cmd.Parameters.AddWithValue("?ParName", OSGconv.deciLat);
    cmd.Parameters.AddWithValue("?Parname2", OSGconv.deciLon);
    cmd.ExecuteNonQuery();

    con.Close();
    }

1 Answer 1

2

It's almost certainly a localisation issue; in the UK we use a full stop as a decimal point, but on the continent, a comma is used instead. Check the country settings for your app and database.

Sign up to request clarification or add additional context in comments.

2 Comments

I have tried it and I can see that C# is sending value as 5.3 and when it goes into query it gets formated to 5,3 and in my table I only see 5. Can you show me on my example what to do
what is the data type on that column?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.