[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


           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:
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
SqlConnection conn = new
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "insert into table (numeric_field) VALUES (@P1)";
SqlParameter p = new SqlParameter("@P1", 12.54);
try {
} catch (Exception ex) {
} finally {
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
  at Mono.Data.Tds.Protocol.Tds.OnTdsErrorMessage
(Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x0000b] in
  at Mono.Data.Tds.Protocol.Tds.ProcessMessage (TdsPacketSubType subType)
[0x000ef] in
  at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x00130] in
  at Mono.Data.Tds.Protocol.Tds.NextResult () [0x0004a] in
  at Mono.Data.Tds.Protocol.Tds.SkipToEnd () [0x00005] in
  at Mono.Data.Tds.Protocol.Tds.ExecuteQuery (System.String sql, Int32 timeout,
Boolean wantResults) [0x00036] in
  at Mono.Data.Tds.Protocol.Tds70.Execute (System.String commandText,
Mono.Data.Tds.TdsMetaParameterCollection parameters, Int32 timeout, Boolean
wantResults) [0x00034] in
  at System.Data.SqlClient.SqlCommand.Execute (Boolean wantResults) [0x0020f]
  at System.Data.SqlClient.SqlCommand.ExecuteNonQuery ()

Expected Results:  
It should inser the new record. If you change
System.Threading.Thread.CurrentThread.CurrentCulture = new


System.Threading.Thread.CurrentThread.CurrentCulture = new

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