Author: andreia
Date: 2007-03-07 17:06:29 -0500 (Wed, 07 Mar 2007)
New Revision: 73914

Modified:
   trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
   trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
Log:
* SqlCommand.cs (ExecuteScalar): when calling stored procedures,
implement support for return of output values in the parameter
collection.

2007-03-07  Andreia Gaita <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog 2007-03-07 
22:02:41 UTC (rev 73913)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog 2007-03-07 
22:06:29 UTC (rev 73914)
@@ -1,3 +1,9 @@
+2007-03-07  Andreia Gaita <[EMAIL PROTECTED]>
+
+       * SqlCommand.cs (ExecuteScalar): when calling stored procedures,
+       implement support for return of output values in the parameter
+       collection.
+
 2007-02-16  Nidhi Rawal  <[EMAIL PROTECTED]>
 
        * SqlParameter.cs (CompareInfo): Implemented the property

Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs     
2007-03-07 22:02:41 UTC (rev 73913)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs     
2007-03-07 22:06:29 UTC (rev 73914)
@@ -443,25 +443,41 @@
 
                public 
 #if NET_2_0
-                override
+               override
 #endif // NET_2_0
-                object ExecuteScalar ()
+               object ExecuteScalar ()
                {
-                       ValidateCommand ("ExecuteScalar");
-                        behavior = CommandBehavior.Default;
                        try {
-                               Execute (CommandBehavior.Default, true);
+                               ValidateCommand ("ExecuteScalar");
+                               behavior = CommandBehavior.Default;
+                               try {
+                                       Execute (CommandBehavior.Default, true);
+                               }
+                               catch (TdsTimeoutException e) {
+                                       throw 
SqlException.FromTdsInternalException ((TdsInternalException) e);
+                               }
+
+                               if (commandType == CommandType.StoredProcedure) 
{
+                                       while (Connection.Tds.NextResult ()) { }
+                                       if 
(Connection.Tds.OutputParameters.Count > 0) {
+                                               int i = 0;
+                                               foreach (SqlParameter p in 
Parameters)
+                                                       if (p.Direction == 
ParameterDirection.Output && i < Connection.Tds.OutputParameters.Count)
+                                                               p.Value = 
Connection.Tds.OutputParameters[i++];
+                                               return 
Connection.Tds.OutputParameters[0];
+                                       }
+                                       return null;
+                               }
+                               else
+                                       if (!Connection.Tds.NextResult () || 
!Connection.Tds.NextRow ())
+                                               return null;
+
+                               object result = Connection.Tds.ColumnValues[0];
+                               return result;
                        }
-                       catch (TdsTimeoutException e) {
-                               throw SqlException.FromTdsInternalException 
((TdsInternalException) e);
+                       finally {
+                               CloseDataReader (true);
                        }
-
-                       if (!Connection.Tds.NextResult () || 
!Connection.Tds.NextRow ())
-                               return null;
-
-                       object result = Connection.Tds.ColumnValues [0];
-                       CloseDataReader (true);
-                       return result;
                }
 
                public XmlReader ExecuteXmlReader ()

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to