Author: suresh
Date: 2005-03-07 08:30:52 -0500 (Mon, 07 Mar 2005)
New Revision: 41519
Modified:
trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
Log:
2005-03-07 Sureshkumar T <[EMAIL PROTECTED]>
* SqlCommand.cs : Set CommandBehavior on
ExecuteReader,ExecuteScalar,ExecuteNonQuery. This is used in
CloseDataReader.
This fixes bug #73252.
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog 2005-03-07
12:04:56 UTC (rev 41518)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog 2005-03-07
13:30:52 UTC (rev 41519)
@@ -1,3 +1,11 @@
+2005-03-07 Sureshkumar T <[EMAIL PROTECTED]>
+
+ * SqlCommand.cs : Set CommandBehavior on
+ ExecuteReader,ExecuteScalar,ExecuteNonQuery. This is used in
+ CloseDataReader.
+
+ This fixes bug #73252.
+
2005-03-03 Sureshkumar T <[EMAIL PROTECTED]>
* SqlClientFactory.cs: While creating command, create using
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
2005-03-07 12:04:56 UTC (rev 41518)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
2005-03-07 13:30:52 UTC (rev 41519)
@@ -366,6 +366,7 @@
{
ValidateCommand ("ExecuteNonQuery");
int result = 0;
+ behavior = CommandBehavior.Default;
try {
Execute (CommandBehavior.Default, false);
@@ -400,14 +401,27 @@
{
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 ();
- Connection.DataReader = new SqlDataReader (this);
- return Connection.DataReader;
+ throw;
+ }
+
+ return Connection.DataReader;
}
public
@@ -417,6 +431,7 @@
object ExecuteScalar ()
{
ValidateCommand ("ExecuteScalar");
+ behavior = CommandBehavior.Default;
try {
Execute (CommandBehavior.Default, true);
}
@@ -435,6 +450,7 @@
public XmlReader ExecuteXmlReader ()
{
ValidateCommand ("ExecuteXmlReader");
+ behavior = CommandBehavior.Default;
try {
Execute (CommandBehavior.Default, true);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches