【发布时间】:2010-09-02 02:02:01
【问题描述】:
我正在使用下面的代码使用第一个表中使用的标识 (info2.Id = info.Id;) 更新第二个表 (Info2)。执行第二次保存时 (info2.Save()) 我收到错误消息:“已经有一个打开的 DataReader 与此命令关联,必须先关闭。”。 谁能看到我做错了什么。
SubSonic 版本 3.0.0.3 和 SQL Server 2005
谢谢
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();
}
}
【问题讨论】: