Monday, November 15, 2010
ExecuteReader with CommanBehavior ( automatically close connection after reading data)
Datareader object has method ExecuteReader, which has overload version that takes CommandBehavior enumeration as parameter.
When you pass above values as argument to ExecuteReader
1. there is no need to close connection explicitly connection get close when you close your reader.
//No need to close connection you just have to write
2. It usefull when you pass reader to another method for processing data.
passing this as parameter , increase performance when you are executing query and retriving single row for exmaple by id field of table.
usefull when reading binary field data, which reduces the memory overhead for large binary fields.