SubSonic Transactions – Inserting to a second table with the return identity from first table

subsonicsubsonic3

I am using the code below to update a second table (Info2) with the identity used from the first table (info2.Id = info.Id;). When the second save is carried out (info2.Save()) I get the error: "There is already an open DataReader associated with this Command which must be closed first.".
Can anyone see what I may be doing wrong.

SubSonic version 3.0.0.3 and SQL Server 2005

Thanks

                using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        Info info = new Info();
                        info.Desc = "Some information";
                        info.Save();

                        Info2 info2 = new Info2();
                        info2.Id = info.Id;
                        info2.Desc = "More information";
                        info2.Save();

                        ts.Complete();
                    }
                }

Best Answer

Looks like you've got the TransactionScope and the SharedDbConnectionScope the wrong way round, try:

using (TransactionScope ts = new TransactionScope())
{
  using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
  {
    Info info = new Info();
    info.Desc = "Some information";
    info.Save();

    Info2 info2 = new Info2();
    info2.Id = info.Id;
    info2.Desc = "More information";
    info2.Save();

    ts.Complete();
  }
}