Hi Dave,
If My understanding is correct, is it "executeReader" in Data Application
blocks.
To make "ExecuteReader" work with commandbehavior.closeconnection, we need
to pass in a external Connection. Following are source code of it:
Private Overloads Shared Function ExecuteReader(ByVal connection As
SqlConnection, _
ByVal transaction
As SqlTransaction, _
ByVal commandType
As CommandType, _
ByVal commandText
As String, _
ByVal
commandParameters() As SqlParameter, _
ByVal
connectionOwnership As SqlConnectionOwnership) As SqlDataReader
'create a command and prepare it for execution
Dim cmd As New SqlCommand()
'create a reader
Dim dr As SqlDataReader
PrepareCommand(cmd, connection, transaction, commandType,
commandText, commandParameters)
' call ExecuteReader with the appropriate CommandBehavior
If connectionOwnership = SqlConnectionOwnership.External Then
dr = cmd.ExecuteReader()
Else
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
End If
'detach the SqlParameters from the command object, so they can
be used again
cmd.Parameters.Clear()
Return dr
End Function 'ExecuteReader
As you see when last parameter is SqlConnectionOwnership.External,
CommandBehavior.CloseConnection will be used. Is this helpful in your
project?
Luke
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)