diff options
author | Sureshkumar T <suresh@mono-cvs.ximian.com> | 2005-03-07 16:30:52 +0300 |
---|---|---|
committer | Sureshkumar T <suresh@mono-cvs.ximian.com> | 2005-03-07 16:30:52 +0300 |
commit | aa267ef781d3f08037a531505a4eb2c400407e38 (patch) | |
tree | 846712d48739ea99b6bd1eae63cde3a8d9c5a996 /mcs/class/System.Data/System.Data.SqlClient | |
parent | 1d7e58c5ed6c5adfb6decdb74fc075e606cfbd46 (diff) |
2005-03-07 Sureshkumar T <tsureshkumar@novell.com>
* SqlCommand.cs : Set CommandBehavior on
ExecuteReader,ExecuteScalar,ExecuteNonQuery. This is used in
CloseDataReader.
This fixes bug #73252.
svn path=/trunk/mcs/; revision=41519
Diffstat (limited to 'mcs/class/System.Data/System.Data.SqlClient')
-rwxr-xr-x | mcs/class/System.Data/System.Data.SqlClient/ChangeLog | 8 | ||||
-rw-r--r-- | mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs | 24 |
2 files changed, 28 insertions, 4 deletions
diff --git a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog index f8565017b9d..8c2b9b17e6e 100755 --- a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog +++ b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog @@ -1,3 +1,11 @@ +2005-03-07 Sureshkumar T <tsureshkumar@novell.com> + + * SqlCommand.cs : Set CommandBehavior on + ExecuteReader,ExecuteScalar,ExecuteNonQuery. This is used in + CloseDataReader. + + This fixes bug #73252. + 2005-03-03 Sureshkumar T <tsureshkumar@novell.com> * SqlClientFactory.cs: While creating command, create using diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs index 560b00449a9..7cee2bff7d7 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs @@ -366,6 +366,7 @@ namespace System.Data.SqlClient { { ValidateCommand ("ExecuteNonQuery"); int result = 0; + behavior = CommandBehavior.Default; try { Execute (CommandBehavior.Default, false); @@ -400,14 +401,27 @@ namespace System.Data.SqlClient { { ValidateCommand ("ExecuteReader"); try { + this.behavior = behavior; + Console.WriteLine (this.behavior.ToString ()); Execute (behavior, true); + Connection.DataReader = new SqlDataReader (this); } catch (TdsTimeoutException e) { - throw SqlException.FromTdsInternalException ((TdsInternalException) e); - } + // if behavior is closeconnection, even if it throws exception + // the connection has to be closed. + if ((behavior & CommandBehavior.CloseConnection) != 0) + Connection.Close (); + throw SqlException.FromTdsInternalException ((TdsInternalException) e); + } catch (SqlException) { + // if behavior is closeconnection, even if it throws exception + // the connection has to be closed. + if ((behavior & CommandBehavior.CloseConnection) != 0) + Connection.Close (); + + throw; + } - Connection.DataReader = new SqlDataReader (this); - return Connection.DataReader; + return Connection.DataReader; } public @@ -417,6 +431,7 @@ namespace System.Data.SqlClient { object ExecuteScalar () { ValidateCommand ("ExecuteScalar"); + behavior = CommandBehavior.Default; try { Execute (CommandBehavior.Default, true); } @@ -435,6 +450,7 @@ namespace System.Data.SqlClient { public XmlReader ExecuteXmlReader () { ValidateCommand ("ExecuteXmlReader"); + behavior = CommandBehavior.Default; try { Execute (CommandBehavior.Default, true); } |