In System.Data/System.Data.SqlClient:
authorSureshkumar T <suresh@mono-cvs.ximian.com>
Fri, 26 Aug 2005 09:31:43 +0000 (09:31 -0000)
committerSureshkumar T <suresh@mono-cvs.ximian.com>
Fri, 26 Aug 2005 09:31:43 +0000 (09:31 -0000)
2005-08-26  Sureshkumar T  <tsureshkumar@novell.com>

* SqlConnection.cs (Open): enable sp_reset_connection.

In Mono.Data.Tds/Mono.Data.Tds.Protocol:
2005-08-26  Sureshkumar T  <tsureshkumar@novell.com>

* Tds70.cs (ExecProc): if no parameters, execute via RPC. parameter
support has to be added.

* Tds.cs (ExecRPC): added virtual method to execute via RPC.

This fixes bug #68978 by enabling execution of sp_reset_connection.

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

mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ChangeLog
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsComm.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsPacketType.cs
mcs/class/System.Data/System.Data.SqlClient/ChangeLog
mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs

index fbf8973f67b3adf29d2f9f2643431bf6bb2d190f..2250409e56a66503af2e8af6802187cf9b87c96e 100644 (file)
@@ -1,3 +1,12 @@
+2005-08-26  Sureshkumar T  <tsureshkumar@novell.com>
+
+       * Tds70.cs (ExecProc): if no parameters, execute via RPC. parameter
+       support has to be added.
+
+       * Tds.cs (ExecRPC): added virtual method to execute via RPC.
+
+       This fixes bug #68978 by enabling execution of sp_reset_connection.
+
 2005-08-24  Sureshkumar T  <tsureshkumar@novell.com>
 
        * Tds.cs: ProcessColumnDetail (): expression columns don't have
index c9d3dd2ba7d6ce6a49566714c460eafd63c49d6b..b9cb6d32006f41ccfea6954218e1402e99bfe720 100644 (file)
@@ -189,6 +189,15 @@ namespace Mono.Data.Tds.Protocol {
 
                #region Public Methods
 
+               internal protected void InitExec () 
+               {
+                       // clean up 
+                       moreResults = true;
+                       doneProc = false;
+                       messages.Clear ();
+                       outputParameters.Clear ();
+               }
+
                public void Cancel ()
                {
                        if (queryInProgress) {
@@ -249,10 +258,7 @@ namespace Mono.Data.Tds.Protocol {
 
                protected void ExecuteQuery (string sql, int timeout, bool wantResults)
                {
-                       moreResults = true;
-                       doneProc = false;
-                       messages.Clear ();
-                       outputParameters.Clear ();
+                       InitExec ();
 
                        Comm.StartPacket (TdsPacketType.Query);
                        Comm.Append (sql);
@@ -263,6 +269,28 @@ namespace Mono.Data.Tds.Protocol {
                                SkipToEnd ();
                }
 
+               protected virtual void ExecRPC (string rpcName, TdsMetaParameterCollection parameters,
+                                               int timeout, bool wantResults)
+               {
+                       Comm.StartPacket (TdsPacketType.DBRPC);
+
+                       byte [] rpcNameBytes = Comm.Encoder.GetBytes (rpcName);
+                       byte rpcNameLength = (byte) rpcNameBytes.Length;
+                       ushort mask = 0x0000;
+                       ushort packetLength =  (ushort) (sizeof (byte) + rpcNameLength +
+                                               sizeof (ushort));
+
+                       Comm.Append (packetLength);
+                       Comm.Append (rpcNameLength);
+                       Comm.Append (rpcNameBytes);
+                       Comm.Append (mask);
+                       
+                       Comm.SendPacket ();
+                       CheckForData (timeout);
+                       if (!wantResults) 
+                               SkipToEnd ();
+               }
+
                public bool NextResult ()
                {
                        if (!moreResults)
@@ -1335,10 +1363,7 @@ namespace Mono.Data.Tds.Protocol {
                 protected IAsyncResult BeginExecuteQueryInternal (string sql, bool wantResults, 
                                                           AsyncCallback callback, object state)
                 {
-                        moreResults = true;
-                       doneProc = false;
-                       messages.Clear ();
-                       outputParameters.Clear ();
+                       InitExec ();
 
                         TdsAsyncResult ar = new TdsAsyncResult (callback, state);
                         ar.TdsAsyncState.WantResults = wantResults;
index 9a4b179a2f47bffb7a8100bcc4ccb35a932a8089..12d5f14bb1a09a12e7fa4b9cd5af51318152f06d 100644 (file)
@@ -376,8 +376,33 @@ namespace Mono.Data.Tds.Protocol {
                        
                public override void ExecProc (string commandText, TdsMetaParameterCollection parameters, int timeout, bool wantResults)
                {
-                       Parameters = parameters;
-                       ExecuteQuery (BuildProcedureCall (commandText), timeout, wantResults);
+                       if (parameters != null && parameters.Count > 0) {
+                               Parameters = parameters;
+                               ExecuteQuery (BuildProcedureCall (commandText), timeout, wantResults);
+                       } else {
+                               ExecRPC (commandText, parameters, timeout, wantResults);
+                       }
+               }
+
+               protected override void ExecRPC (string rpcName, TdsMetaParameterCollection parameters, 
+                                                int timeout, bool wantResults)
+               {
+                       // clean up 
+                       InitExec ();
+                       
+                       Comm.StartPacket (TdsPacketType.RPC);
+
+                       Comm.Append ( (short) rpcName.Length);
+                       Comm.Append (rpcName);
+                       Comm.Append ( (short) 0); //no meta data
+
+                       // FIXME : support parameters here
+
+                       Comm.SendPacket ();
+                       CheckForData (timeout);
+                       if (!wantResults) 
+                               SkipToEnd ();
+
                }
 
                public override void Execute (string commandText, TdsMetaParameterCollection parameters, int timeout, bool wantResults)
index 4754bfedfc80ca54ba96144e765c780e221a97ad..00a39a660826c292f0e08a3315c1188beaeee9c2 100644 (file)
@@ -126,6 +126,7 @@ namespace Mono.Data.Tds.Protocol {
                }
 
                internal Encoding Encoder {
+                       get { return encoder; }
                        set { encoder = value; }
                }
                
index 2ab6f2029ea43f8b9c241cb7743c3b3e9e88a52c..3443f3d74d69a8bb0872265ea754603da43f1d18 100644 (file)
@@ -42,6 +42,8 @@ namespace Mono.Data.Tds.Protocol {
                Logon70 = 0x10,
                SspAuth = 0x11,
                Logoff = 0x71,
-               Normal = 0x0f
+               Normal = 0x0f,
+               DBRPC = 0xe6,
+               RPC = 0x3
        }
 }
index e9910d0eba148799ee5b4939aab36f646a768c71..c648adbfe6a365b2bd85add7cd972450cbe271d6 100644 (file)
@@ -1,3 +1,7 @@
+2005-08-26  Sureshkumar T  <tsureshkumar@novell.com>
+
+       * SqlConnection.cs (Open): enable sp_reset_connection.
+
 2005-08-25  Sureshkumar T  <tsureshkumar@novell.com>
 
        * SqlCommandBuilder.cs: BuildInformation (): continue on columns
index da883b020e32cd044bc2352512d1dc2183c898ba..fc46c27a79d84a75fdd583d97f9edc09f05a674e 100644 (file)
@@ -501,15 +501,10 @@ namespace System.Data.SqlClient {
                                                pool.ReleaseConnection (tds);
                                        throw;
                                }
+                       } else if (connectionReset) {
+                               tds.Reset ();
                        }
 
-                       /* Not sure ebout removing these 2 lines.
-                        * The command that gets to the sql server is just
-                        * 'sp_reset_connection' and it fails.
-                        * Either remove them definitely or fix it
-                       else if (connectionReset)
-                               tds.ExecProc ("sp_reset_connection");
-                       */
                         disposed = false; // reset this, so using () would call Close ().
                        ChangeState (ConnectionState.Open);
                }