[Mono-bugs] [Bug 82047][Wis] New - Error when trying to add a row with a DateTime field into an Italian SqlServer.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Mon Jul 9 10:42:30 EDT 2007
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by s.martinz at caleidoscopio.it.
http://bugzilla.ximian.com/show_bug.cgi?id=82047
--- shadow/82047 2007-07-09 10:42:30.000000000 -0400
+++ shadow/82047.tmp.23571 2007-07-09 10:42:30.000000000 -0400
@@ -0,0 +1,128 @@
+Bug#: 82047
+Product: Mono: Class Libraries
+Version: 1.2
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Sys.Data.SqlClient
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: s.martinz at caleidoscopio.it
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Error when trying to add a row with a DateTime field into an Italian SqlServer.
+
+Description of Problem:
+Error when trying to add a new row with a DateTime field into an Italian
+SqlServer.
+
+Steps to reproduce the problem:
+1. Create a database with one table with one DateTime field on an Italian
+SqlServer database
+2. Run the following simple program
+
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ SqlConnection conn = new SqlConnection("...");
+ string cmdText = "SELECT * FROM TestMONODateTime";
+
+ SqlCommand cmd = new SqlCommand(cmdText, conn);
+ SqlDataAdapter da = new SqlDataAdapter(cmd);
+ DataSet ds = new DataSet();
+
+ SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(da);
+
+ da.Fill(ds);
+ DataTable dt = ds.Tables[0];
+
+ DataRow row = dt.NewRow();
+ row["DateTimeField"] = new DateTime(2007, 07, 10);
+ dt.Rows.Add(row);
+ da.Update(ds);
+ }
+ }
+
+Actual Results:
+New row cannot be added because DateTime format is not recognized as a
+valid one. Here is the detailed error (message is in italian, but basically
+it says that it is impossible to convert from varchar to datetime)
+
+
+Unhandled Exception: System.Data.SqlClient.SqlException: Si è verificato un
+errore durante la conversione del tipo di dati da varchar a datetime.
+ at System.Data.SqlClient.SqlConnection.ErrorHandler (System.Object
+sender, Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e)
+[0x00000] in
+/tmp/scratch/BUILD/mono-1.2.4/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs:300
+
+ at (wrapper delegate-invoke)
+System.MulticastDelegate:invoke_void_object_TdsInternalErrorMessageEventArgs
+(object,Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs)
+ at Mono.Data.Tds.Protocol.Tds.OnTdsErrorMessage
+(Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x0000b] in
+/tmp/scratch/BUILD/mono-1.2.4/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1343
+
+ at Mono.Data.Tds.Protocol.Tds.ProcessMessage (TdsPacketSubType subType)
+[0x000ef] in
+/tmp/scratch/BUILD/mono-1.2.4/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1383
+
+ at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x00130] in
+/tmp/scratch/BUILD/mono-1.2.4/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1431
+
+ at Mono.Data.Tds.Protocol.Tds.NextResult () [0x0004a] in
+/tmp/scratch/BUILD/mono-1.2.4/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:478
+
+ at System.Data.SqlClient.SqlDataReader.NextResult () [0x00026] in
+/tmp/scratch/BUILD/mono-1.2.4/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs:1117
+
+ at System.Data.SqlClient.SqlDataReader..ctor
+(System.Data.SqlClient.SqlCommand command) [0x00000]
+ at (wrapper remoting-invoke-with-check)
+System.Data.SqlClient.SqlDataReader:.ctor (System.Data.SqlClient.SqlCommand)
+ at System.Data.SqlClient.SqlCommand.ExecuteReader (CommandBehavior
+behavior) [0x0002f] in
+/tmp/scratch/BUILD/mono-1.2.4/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs:471
+
+
+Expected Results:
+New row should be correctly added to the table in the database
+
+How often does this happen?
+Always
+
+Additional Information:
+Here are the 2 (with Mono and MS.NET) actual queries run on the db, as seen
+using SQL Profiler:
+ - with Mono on Linux: exec sp_executesql N'INSERT INTO [TestMONODateTime]
+([DateTimeField]) VALUES (@p1)', N'@p1 datetime', @p1='Jul 10 2007
+12:00:00 AM'
+ - with MS.NET on Win: exec sp_executesql N'INSERT INTO [TestMONODateTime]
+([DateTimeField]) VALUES (@p1)', N'@p1 datetime', @p1 = 'lug 10 2007
+12:00:00:000AM'
+
+As you can see with MS.NET the month name is expressed in Italian and
+that's indipendent from the client thread culture.
+With Mono, instead it is always expressed in English. This is due to the
+conversion performed in
+'/trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs'; see the
+method FormatParameter() - when the parameter is datetime (it uses
+InvariantCulture):
+ ...
+ case "datetime":
+ DateTime d = Convert.ToDateTime (parameter.Value);
+ value =
+String.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0:MMM
+dd yyyy hh:mm:ss tt}'", d );
+ ...
+
+I haven't tried, but I suppose the same issue could be repro on other
+localized SqlServer.
+
+Cheers,
+Stefano
More information about the mono-bugs
mailing list