Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEran Domb <eran@mono-cvs.ximian.com>2004-01-12 11:53:13 +0300
committerEran Domb <eran@mono-cvs.ximian.com>2004-01-12 11:53:13 +0300
commit476a161d9f1e852d5f6a06a5906c8ce3e1c157ba (patch)
tree251918220ddb7ef5c7897f6102875bbf07956b70 /mcs/class/System.Data/System.Data.Common
parent34907526abc5374d9168922fd72f2fc805230e44 (diff)
Use ExecuteReader instead of ExecuteNonQuery. We need to use the CommandBehavior parameter, so the connection will be closed if neede.
svn path=/trunk/mcs/; revision=21975
Diffstat (limited to 'mcs/class/System.Data/System.Data.Common')
-rw-r--r--mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs17
1 files changed, 15 insertions, 2 deletions
diff --git a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
index ba31c526d66..0e3c91269ac 100644
--- a/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
+++ b/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
@@ -699,13 +699,21 @@ namespace System.Data.Common {
parameter.Value = row [dsColumnName, rowVersion];
}
}
-
+
+ CommandBehavior commandBehavior = CommandBehavior.Default;
if (command.Connection.State == ConnectionState.Closed)
+ {
command.Connection.Open ();
+ commandBehavior |= CommandBehavior.CloseConnection;
+ }
+ IDataReader reader = null;
try
{
- int tmp = command.ExecuteNonQuery ();
+ // use ExecuteReader because we want to use the commandbehavior parameter.
+ // so the connection will be closed if needed.
+ reader = command.ExecuteReader (commandBehavior);
+ int tmp = reader.RecordsAffected;
// if the execute does not effect any rows we throw an exception.
if (tmp == 0)
throw new DBConcurrencyException("Concurrency violation: the " + commandName +"Command affected 0 records.");
@@ -720,6 +728,11 @@ namespace System.Data.Common {
else
throw e;
}
+ finally
+ {
+ if (reader != null)
+ reader.Close ();
+ }
}
return updateCount;