以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- SQL事务 _SortKey没有保存 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=171625) |
-- 作者:aoc103 -- 发布时间:2021/9/4 21:21:00 -- SQL事务 _SortKey没有保存 Dim pd As DataTable \'主表表 Dim od As DataTable \'明细表 Dim od2 As DataTable \'排产总表 Dim cmd As New SqlCommand() cmd.C Try cmd.BeginTransaction() cmd.CommandText = "Selec t * Fro m 排产登记表_主表 Wher e [_identify] Is Null" \'无需加载任何数据 pd = cmd.ExecuteReader(True) cmd.CommandText = "Selec t * Fro m 排产登记表_明细 Wher e [_identify] Is Null" od = cmd.ExecuteReader(True) Dim dr As DataRow = pd.AddNew() \'增加一个订单,注意无需给新增行指定OrderID. Dim localtr As Row =Tables("排产登记表_主表").Current dr("单据编号") = localtr("单据编号") dr("登记员") = localtr("登记员") dr("登记日期") = localtr("登记日期") dr("备注")=localtr("备注") dr("审核结果")="待审核" pd.Save() \'必须提前保存主表表, 这样主表ID列的值才是实际生成的主键值. For Each r As Row In Tables("排产登记表_明细").Rows Dim tr = od.AddNew() \'增加订单明细 tr("_SortKey")=r("_SortKey") ‘就这行数据 保存后在后台看数据发现_SortKey是没有数据的 tr("商品编号")=r("商品编号") tr("排产目的")=r("排产目的") tr("生产数量")=r("生产数量") tr("最低数量")=r("最低数量") tr("最多数量")=r("最多数量") tr("打托")=r("打托") tr("控数")=r("控数") tr("备注")=r("备注") tr("父表ID")=dr("_identify") \'将自动生成的ID赋值给新增的订单明细 Next od.save() |
-- 作者:有点蓝 -- 发布时间:2021/9/5 20:22:00 -- 说明Tables("排产登记表_明细")本身就没有"_SortKey"数据,Tables("排产登记表_明细")是窗口表?怎么绑定数据的? For Each r As Row In Tables("排产登记表_明细").Rows msgbox(r("_SortKey") ) Dim tr = od.AddNew() \'增加订单明细 tr("_SortKey")=r("_SortKey") |