[Mono-bugs] [Bug 382734] New: Wrong DateTime paramter conversion

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Apr 23 07:18:59 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=382734


           Summary: Wrong DateTime paramter conversion
           Product: Mono: Class Libraries
           Version: 1.9.0
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: Blocker
          Priority: P5 - None
         Component: Sys.Data
        AssignedTo: bnc-blr-team-mono at forge.provo.novell.com
        ReportedBy: josef.semmler at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Description of Problem:

If you try to pass a DateTime paramter to a query/SP you get a exception like
this:
 System.Data.SqlClient.SqlException: Fehler beim Konvertieren von Datentyp
varchar in datetime.
  at System.Data.SqlClient.SqlConnection.ErrorHandler (System.Object sender,
Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x00000]
  at Mono.Data.Tds.Protocol.Tds.OnTdsErrorMessage
(Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x00000]
  at Mono.Data.Tds.Protocol.Tds.ProcessMessage (TdsPacketSubType subType)
[0x00000]
  at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x0000
..

It seems to be related to the language settings of the database server (i use
mssql), if it is set to "english" - the conversion seems to work ... if the
server is e.g. "german" you get the exception.


Steps to reproduce the problem:
Use the following code:

string query = "select 1";
SqlConnection cnn = new SqlConnection("Data Source=XXX;UID=XXX;PWD=XXX;Initial
Catalog=Northwind");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@BirthDate", new DateTime(2008, 3, 1, 0, 0, 0));
Console.WriteLine(cmd.ExecuteNonQuery());

you need a database server which is not set to "english" ... i have a "german"
one. 

If you set as date "2008, 4, 1, 0, 0, 0" it works ... mai seems to cause
problems, too.


Actual Results:
System.Data.SqlClient.SqlException: Fehler beim Konvertieren von Datentyp
varchar in datetime.
  at System.Data.SqlClient.SqlConnection.ErrorHandler (System.Object sender,
Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x00000]
  at Mono.Data.Tds.Protocol.Tds.OnTdsErrorMessage
(Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x00000]
  at Mono.Data.Tds.Protocol.Tds.ProcessMessage (TdsPacketSubType subType)
[0x00000]
  at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x00000]
  at Mono.Data.Tds.Protocol.Tds.NextResult () [0x00000]
  at (wrapper remoting-invoke-with-check) Mono.Data.Tds.Protocol.Tds:NextResult
()
  at Mono.Data.Tds.Protocol.Tds.SkipToEnd () [0x00000]
  at (wrapper remoting-invoke-with-check) Mono.Data.Tds.Protocol.Tds:SkipToEnd
()
  at Mono.Data.Tds.Protocol.Tds.ExecuteQuery (System.String sql, Int32 timeout,
Boolean wantResults) [0x00000]
  at Mono.Data.Tds.Protocol.Tds70.Execute (System.String commandText,
Mono.Data.Tds.TdsMetaParameterCollection parameters, Int32 timeout, Boolean
wantResults) [0x00000]
  at System.Data.SqlClient.SqlCommand.Execute (CommandBehavior behavior,
Boolean wantResults) [0x00000]

Expected Results:
no exception and proper valid passing of the DateTime to the query
(attention: The query does not even use the paramter!)

How often does this happen? 
!always"

Additional Information:
There seems to be at least one other ticket describing this problem with an old
mono version ... 
https://bugzilla.novell.com/show_bug.cgi?id=321508

This issues means, that you cannot use DateTime with non english database
servers.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list