[Mono-bugs] [Bug 547251] New: Decimal parameter of SqlCommand causes exception when executing Command in non-english localizations
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Oct 15 10:04:43 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=547251
Summary: Decimal parameter of SqlCommand causes exception when
executing Command in non-english localizations
Classification: Mono
Product: Mono: Class Libraries
Version: 2.4.x
Platform: x86-64
OS/Version: RHEL 5
Status: NEW
Severity: Critical
Priority: P5 - None
Component: Sys.Data.SqlClient
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: stefano.sapienti at apsystems.it
QAContact: mono-bugs at lists.ximian.com
Found By: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14)
Gecko/2009082707 Firefox/3.0.14 (.NET CLR 3.5.30729)
I decided to create a new bug report based on
https://bugzilla.novell.com/show_bug.cgi?id=319320 cause it was closed many
years ago in the wrong way.
The problem is still there and it was hidden cause you are using english
localization. It happens in localizations that use "," as decimal separator
instead of "."
Reproducible: Always
Steps to Reproduce:
1.Create a test table into an SQL Server database with a field of type float.
2. Run this piece of code:
System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("it-IT");
SqlConnection conn = new
SqlConnection("server=servername;database=databasename;User
ID=username;Pwd=password;");
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "insert into table (numeric_field) VALUES (@P1)";
SqlParameter p = new SqlParameter("@P1", 12.54);
cmd.Parameters.Add(p);
try {
conn.Open();
cmd.ExecuteNonQuery();
Console.WriteLine("Done.");
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
} finally {
conn.Close();
}
Actual Results:
You receive the error:
System.Data.SqlClient.SqlException: Must pass parameter number 4 and subsequent
parameters as '@name = value'. After the form '@name = value' has been used,
all subsequent parameters must be passed in the form '@name = value'.
at System.Data.SqlClient.SqlConnection.ErrorHandler (System.Object sender,
Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x00032] in
/root/download/mono/mono-2.4.2.3/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs:314
at Mono.Data.Tds.Protocol.Tds.OnTdsErrorMessage
(Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x0000b] in
/root/download/mono/mono-2.4.2.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1593
at Mono.Data.Tds.Protocol.Tds.ProcessMessage (TdsPacketSubType subType)
[0x000ef] in
/root/download/mono/mono-2.4.2.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1633
at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x00130] in
/root/download/mono/mono-2.4.2.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1680
at Mono.Data.Tds.Protocol.Tds.NextResult () [0x0004a] in
/root/download/mono/mono-2.4.2.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:612
at Mono.Data.Tds.Protocol.Tds.SkipToEnd () [0x00005] in
/root/download/mono/mono-2.4.2.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:685
at Mono.Data.Tds.Protocol.Tds.ExecuteQuery (System.String sql, Int32 timeout,
Boolean wantResults) [0x00036] in
/root/download/mono/mono-2.4.2.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:560
at Mono.Data.Tds.Protocol.Tds70.Execute (System.String commandText,
Mono.Data.Tds.TdsMetaParameterCollection parameters, Int32 timeout, Boolean
wantResults) [0x00034] in
/root/download/mono/mono-2.4.2.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs:540
at System.Data.SqlClient.SqlCommand.Execute (Boolean wantResults) [0x0020f]
in
/root/download/mono/mono-2.4.2.3/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs:532
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery ()
Expected Results:
It should inser the new record. If you change
System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("it-IT");
with
System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-GB");
it works.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list