How can we force the connection object to close after my datareader is closed

Q

How can we force the connection object to close after my datareader is closed ?

✍: Guest

A

Command method Executereader takes a parameter called as CommandBehavior where in we can specify saying close connection automatically after the Datareader is close.
pobjDataReader = pobjCommand.ExecuteReader(CommandBehavior.CloseConnection)

2007-10-24, 5565👍, 0💬