View Ticket
Not logged in
Ticket UUID: 83949ee3dbe8256b0b7be543748704ba12bb271e
Title: Culture-specific number format used for DbType.VarNumeric parameters
Status: Closed Type: Incident
Severity: Important Priority: Medium
Subsystem: Data_Reader Resolution: Works_As_Designed
Last Modified: 2018-11-07 02:14:58
Version Found In: 1.109.1
User Comments:
anonymous added on 2018-08-26 14:55:10:
Following test fails on locales with number format, which differ from invariant one (e.g. nl-NL). Not sure what other types could be affected, at least DbType.Decimal looks like working as expected.

//Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL");
var cmd = conn.CreateCommand();
var value = 1.1m;
cmd.CommandText = "SELECT @p";

var p = cmd.CreateParameter();
p.DbType = System.Data.DbType.VarNumeric;
p.Value = value;
p.ParameterName = "@p";

using (var rd = cmd.ExecuteReader())
	var valueFromDB = rd.GetValue(0);

        // "1,1" != "1.1"
	Assert.AreEqual("1.1", valueFromDB);

mistachkin added on 2018-08-26 22:44:28:
To have an untyped value like this use the Invariant culture, please use the
connection flag "BindInvariantText", e.g.:

    "Data Source=:memory:;Flags=BindInvariantText;"