Tard mais efficace comme solution qui nous vient de Zifter de Belgique:
If you concatenate a string with a decimal, underlying it will call the Decimal.ToString method. This will take the current culture into account.
You can specify a specific culture as parameter to display it differently, for example
myValue.ToString(CultureInfo.CreateSpecificCulture("en-GB")
But as a general rule, it is bad practice to build your sql update statement by concatenating (consider SQL injection).
You'd better use a SqlParameter.
1 2 3 4 5
| Dim myValue As Decimal = 23.56D
Dim command As New SqlCommand("update mytable set [myfield] = @myValue", connection)
command.Parameters.Add(New SqlParameter("@myValue", myValue))
command.ExecuteNonQuery() |
This will prevent SQL injection and will handle the decimal separator correctly.
Partager