diff options
author | Senganal T <senga@mono-cvs.ximian.com> | 2005-10-27 14:46:11 +0400 |
---|---|---|
committer | Senganal T <senga@mono-cvs.ximian.com> | 2005-10-27 14:46:11 +0400 |
commit | a34e1cf63da3d207bf69a90eed2ea8642a339d0b (patch) | |
tree | 8d7f239f4327691aeff021ff7109ff75c350115f /mcs/class/System.Data/System.Data.SqlClient | |
parent | f72b9ee090da5cdf3e4f6d19c3e6e3da95e7e134 (diff) |
2005-10-27 Senganal T <tsenganal@novell.com>
* Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs :
- Added a virtual method IsValidRowCount ()
- Modified the way RecordsAffected is being counted
* Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs :
- Overrode IsValidRowCount(), to check if the rowcount
returned by sqlserver is valid.
* System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs :
- Added Testcase for bug #75698
* System.Data/System.Data.SqlClient/SqlCommand.cs
* System.Data/System.Data.SqlClient/SqlDataReader.cs :
-Made changes so that the number of rows affected can be got directly
from Tds regardsless of the type of query.Fixes bug #75698
svn path=/trunk/mcs/; revision=52268
Diffstat (limited to 'mcs/class/System.Data/System.Data.SqlClient')
3 files changed, 15 insertions, 36 deletions
diff --git a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog index 2f26a67e4c0..3560088e4de 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog +++ b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog @@ -1,3 +1,11 @@ +2005-10-27 Senganal T <tsenganal@novell.com> + + * SqlCommand.cs + * SqlDataReader.cs + + Made changes so that the number of rows affected can be got directly from + Tds regardsless of the type of query.Fixes bug #75698 + 2005-10-19 Senganal T <tsenganal@novell.com> * SqlConnection.cs (SetProperties) : diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs index 50bdeb99868..b36c66e8451 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs @@ -320,7 +320,7 @@ namespace System.Data.SqlClient { private void Execute (CommandBehavior behavior, bool wantResults) { - Connection.Tds.RecordsAffected = 0; + Connection.Tds.RecordsAffected = -1; TdsMetaParameterCollection parms = Parameters.MetaParameters; if (preparedStatement == null) { bool schemaOnly = ((behavior & CommandBehavior.SchemaOnly) > 0); @@ -370,19 +370,7 @@ namespace System.Data.SqlClient { try { Execute (CommandBehavior.Default, false); - if (commandType == CommandType.StoredProcedure) - result = -1; - else { - // .NET documentation says that except for INSERT, UPDATE and - // DELETE where the return value is the number of rows affected - // for the rest of the commands the return value is -1. - if ((CommandText.ToUpper().IndexOf("UPDATE")!=-1) || - (CommandText.ToUpper().IndexOf("INSERT")!=-1) || - (CommandText.ToUpper().IndexOf("DELETE")!=-1)) - result = Connection.Tds.RecordsAffected; - else - result = -1; - } + result = Connection.Tds.RecordsAffected; } catch (TdsTimeoutException e) { throw SqlException.FromTdsInternalException ((TdsInternalException) e); @@ -595,7 +583,7 @@ namespace System.Data.SqlClient { object state) { IAsyncResult ar = null; - Connection.Tds.RecordsAffected = 0; + Connection.Tds.RecordsAffected = -1; TdsMetaParameterCollection parms = Parameters.MetaParameters; if (preparedStatement == null) { bool schemaOnly = ((behavior & CommandBehavior.SchemaOnly) > 0); @@ -675,20 +663,8 @@ namespace System.Data.SqlClient { ValidateAsyncResult (ar, "EndExecuteNonQuery"); EndExecuteInternal (ar); - int ret; - if (commandType == CommandType.StoredProcedure) - ret = -1; - else { - // .NET documentation says that except for INSERT, UPDATE and - // DELETE where the return value is the number of rows affected - // for the rest of the commands the return value is -1. - if ((CommandText.ToUpper().IndexOf("UPDATE")!=-1) || - (CommandText.ToUpper().IndexOf("INSERT")!=-1) || - (CommandText.ToUpper().IndexOf("DELETE")!=-1)) - ret = Connection.Tds.RecordsAffected; - else - ret = -1; - } + int ret = Connection.Tds.RecordsAffected; + GetOutputParameters (); ( (SqlAsyncResult) ar).Ended = true; return ret; diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs index 58641400d12..6630e38b289 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs @@ -59,7 +59,6 @@ namespace System.Data.SqlClient { bool disposed = false; int fieldCount; bool isClosed; - bool isSelect; bool moreResults; int resultsRead; int rowsRead; @@ -86,8 +85,7 @@ namespace System.Data.SqlClient { resultsRead = 0; fieldCount = 0; isClosed = false; - isSelect = (command.CommandText.Trim ().ToUpper ().StartsWith ("SELECT")); - command.Tds.RecordsAffected = 0; + command.Tds.RecordsAffected = -1; NextResult (); } @@ -141,10 +139,7 @@ namespace System.Data.SqlClient { #endif // NET_2_0 int RecordsAffected { get { - if (isSelect) - return -1; - else - return command.Tds.RecordsAffected; + return command.Tds.RecordsAffected; } } |