@@ -58,6 +58,7 @@ type internal Connection = Choice<string, SqlConnection, SqlTransaction>
5858type ``ISqlCommand Implementation`` ( cfg : DesignTimeConfig , connection : Connection , commandTimeout ) =
5959
6060 let cmd = new SqlCommand( cfg.SqlStatement, CommandTimeout = commandTimeout)
61+
6162 let manageConnection =
6263 match connection with
6364 | Choice1Of3 connectionString ->
@@ -73,7 +74,7 @@ type ``ISqlCommand Implementation``(cfg: DesignTimeConfig, connection: Connectio
7374
7475 do
7576 cmd.CommandType <- if cfg.IsStoredProcedure then CommandType.StoredProcedure else CommandType.Text
76- cmd.Parameters.AddRange( cfg.Parameters)
77+ cmd.Parameters.AddRange( cfg.Parameters)
7778
7879 let getReaderBehavior () =
7980 seq {
@@ -169,6 +170,8 @@ type ``ISqlCommand Implementation``(cfg: DesignTimeConfig, connection: Connectio
169170
170171 interface IDisposable with
171172 member this.Dispose () =
173+ if manageConnection then
174+ cmd.Connection.Dispose()
172175 cmd.Dispose()
173176
174177 static member internal SetParameters ( cmd : SqlCommand , parameters : ( string * obj )[]) =
@@ -305,9 +308,9 @@ type ``ISqlCommand Implementation``(cfg: DesignTimeConfig, connection: Connectio
305308 assert ( rank = ResultRank.Sequence)
306309 box xs
307310
308- static member internal ExecuteNonQuery manageConnection ( cmd , _ , parameters , _ ) =
311+ static member internal ExecuteNonQuery ( manageConnection : bool ) ( cmd , _ , parameters , _ ) =
309312 `` ISqlCommand Implementation `` .SetParameters( cmd, parameters)
310- use openedConnection = cmd.Connection.UseLocally( manageConnection )
313+ use openedConnection = cmd.Connection.UseLocally( manageConnection)
311314 let recordsAffected = cmd.ExecuteNonQuery()
312315 for i = 0 to parameters.Length - 1 do
313316 let name , _ = parameters.[ i]
0 commit comments