OleDbDataReader oReader = oCommand.ExecuteReader(CommandBehavior.CloseConnec tion);

The argument "CommandBehavior.CloseConnection" will specify that the connection object will close automatically when we close the Reader object.

The sample code is given below:

OleDbConnection connectionObj = new OleDbConnection(connectionString);
OleDbCommand commandObj = new OleDbCommand();
OleDbDataReader readerObj = null;
commandObj = new OleDbCommand(sqlQuery, connectionObj);
readerObj = commandObj.ExecuteReader(CommandBehavior.CloseConn ection);

Now when we close the Reader object then the Connection object will close automatically.