Hi all, I am trying to encapsulate data access.

I want to make a function that returns a data reader.

If I then close that data reader will it close the command object that was used to 
open it.
(I know it will close the connection)

Here is some code showing what I mean
-------

Function GetDataReader(strSql as string) as sqlclient.SqlDataReader

Dim objCmd As SqlClient.SqlCommand
Dim objDr As SqlClient.SqlDataReader
objCmd = New SqlClient.SqlCommand(strSQL, New 
SqlClient.SqlConnection(HttpContext.Current.Application("dbconnect")))

objCmd.Connection.Open()

objDr = objCmd.ExecuteReader(CommandBehavior.CloseConnection)

Return objDr

End Function

------

In the normal code.....

clientDr=GetDataReader(clientSQL)

clientDr.close()

.......

Will this be sufficient to free up the objects?

Thank you very much

John Best

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to