SubSonic: MySqlDataReader closes connection.

Posted by SchlaWiener on Stack Overflow See other posts from Stack Overflow or by SchlaWiener
Published on 2010-06-02T08:13:38Z Indexed on 2010/06/02 8:23 UTC
Read the original article Hit count: 387

Filed under:
|
|

I am using SubSonic 2.1 and entcountered a problem while executing a Transaction with

SharedDbConnectionScope and TransactionScope. The problem is that in the obj.Save() method I get an "The connection must be valid and open" exception

I tracked down the problem to this line:

// Loads a SubSonic ActiveRecord object
User user = new User(User.Columns.Username, "John Doe");

in this Constructor of the User class a method "LoadParam" is called which eventually does

if (rdr != null)
    rdr.Close();

It looks like the rdr.Close() implicitly closes my connection which is fine when using the AutomaticConnection. But during a transaction it is usally not a good idea to close the connection :-)

My Question is if this is by design or if it's an error in the MySqlDataReader.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about subsonic