Author: gonzalo
Date: 2005-03-18 19:17:24 -0500 (Fri, 18 Mar 2005)
New Revision: 42023

Modified:
   trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ChangeLog
   trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs
   trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsConnectionPool.cs
Log:
2005-03-18 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * Tds70.cs: turns out that sp_reset_connection procedure might not be
        found ("Invalid object name 'sp_reset_connection'"). In this case, and
        if we get a proper state ('Class' property in the SqlException), just
        ignore the error.

        * TdsConnectionPool.cs: if the connection cannot be reset, attemp to
        disconnect it before losing the last reference to it.



Modified: trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ChangeLog      
2005-03-18 22:29:03 UTC (rev 42022)
+++ trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ChangeLog      
2005-03-19 00:17:24 UTC (rev 42023)
@@ -1,3 +1,13 @@
+2005-03-18 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * Tds70.cs: turns out that sp_reset_connection procedure might not be
+       found ("Invalid object name 'sp_reset_connection'"). In this case, and
+       if we get a proper state ('Class' property in the SqlException), just
+       ignore the error.
+
+       * TdsConnectionPool.cs: if the connection cannot be reset, attemp to
+       disconnect it before losing the last reference to it.
+
 2005-03-11 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * Tds.cs: set the charset for MS SQL 2000. Patch from Aleksandar

Modified: trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs
===================================================================
--- trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs       
2005-03-18 22:29:03 UTC (rev 42022)
+++ trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs       
2005-03-19 00:17:24 UTC (rev 42023)
@@ -353,16 +353,19 @@
 
                public override bool Reset ()
                {
-                       try
-                       {
+                       try {
                                ExecProc ("exec sp_reset_connection");
-                               return true;
+                       } catch (Exception e) {
+                               System.Reflection.PropertyInfo pinfo = 
e.GetType ().GetProperty ("Class");
+                               if (pinfo != null && pinfo.PropertyType == 
typeof (byte)) {
+                                       byte klass = (byte) pinfo.GetValue (e, 
null);
+                                       // 11 to 16 indicates error that can be 
fixed by the user such as 'Invalid object name'
+                                       if (klass < 11 || klass > 16)
+                                               return false;
+                               }
                        }
-                       catch
-                       {
-                               Console.WriteLine ("Error reseting");
-                               return false;
-                       }
+
+                       return true;
                }
 
                public override void ExecPrepared (string commandText, 
TdsMetaParameterCollection parameters, int timeout, bool wantResults)

Modified: 
trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsConnectionPool.cs
===================================================================
--- trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsConnectionPool.cs   
2005-03-18 22:29:03 UTC (rev 42022)
+++ trunk/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsConnectionPool.cs   
2005-03-19 00:17:24 UTC (rev 42023)
@@ -131,6 +131,9 @@
                                                connection = (ITds) list 
[list.Count - 1];
                                                list.RemoveAt (list.Count - 1);
                                                if (!connection.Reset ()) {
+                                                       try {
+                                                               
connection.Disconnect ();
+                                                       } catch {}
                                                        connection = null;
                                                        continue;
                                                }

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

Reply via email to