DBCommand using block -
i have following code:
using (mysqlconnection conn = new mysqlconnection(connstr)) { conn.open(); cmd = conn.createcommand(); cmd.commandtext = "select * events"; cmd.commandtype = commandtype.text; cmd.executenonquery(); } from reading few articles on site, suggested dbcommand should in using block, however, can't see why needed. connection closed, dbcommand holding on requires using block? case if class inherits idisposable must use using block or manually called dispose?
i ran simulator 100 threads on code above, , code using block on dbcommand , see no real differences in memory usage.
dbcommand abstract, , not presuppose native resources vendor-specific subclass hold, , in order should released. proper nesting of using blocks seems reasonable implicit coding convention.
Comments
Post a Comment