Browse Source

2005-12-03 Senganal T <[email protected]>
* Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs :
- FormatParameter () : For DateTime Parameters, convert the value if
specified as a string. Fixes bug#76880
* System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs :
- Added testcase for bug #76880


svn path=/trunk/mcs/; revision=53881

Senganal T 20 years ago
parent
commit
2270af43c7

+ 6 - 0
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ChangeLog

@@ -1,3 +1,9 @@
+2005-12-03  Senganal T  <[email protected]>
+
+	* Tds70.cs : 
+		- FormatParameter () : For DateTime Parameters, convert the value if
+		specified as a string. Fixes bug#76880
+
 2005-11-24  Senganal T  <[email protected]>
 
 	* Tds.cs 

+ 1 - 1
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs

@@ -440,7 +440,7 @@ namespace Mono.Data.Tds.Protocol {
 			switch (parameter.TypeName) {
                         case "smalldatetime":
 			case "datetime":
-				DateTime d = (DateTime)parameter.Value;
+				DateTime d = Convert.ToDateTime (parameter.Value);
 				value = String.Format(System.Globalization.CultureInfo.InvariantCulture, 
                                                       "'{0:MMM dd yyyy hh:mm:ss tt}'", d );
                                 break;

+ 4 - 0
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog

@@ -1,3 +1,7 @@
+2005-12-03  Senganal T  <[email protected]>
+
+	* SqlCommandTest.cs : Added testcase for bug #76880
+
 2005-11-23  Senganal T  <[email protected]>
 
 	* SqlCommandTest.cs : Added testcases for bug #76778

+ 16 - 0
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs

@@ -661,6 +661,22 @@ namespace MonoTests.System.Data.SqlClient
 			}
 		}
 
+		// Test for bug #76880
+		[Test]
+		public void DateTimeParameterTest ()
+		{
+			SqlConnection conn = new SqlConnection (connectionString); 
+			using (conn) {
+				conn.Open ();
+				SqlCommand cmd = conn.CreateCommand ();
+				cmd.CommandText = "select * from datetime_family where type_datetime=@p1";
+				cmd.Parameters.Add ("@p1", SqlDbType.DateTime).Value= "10-10-2005";
+				// shudnt cause and exception
+				SqlDataReader rdr = cmd.ExecuteReader ();
+				rdr.Close ();
+			}
+		}
+
 		/**
 		 * Verifies whether an enum value is converted to a numeric value when
 		 * used as value for a numeric parameter (bug #66630)