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:
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;