两个数据表同时插入数据怎么办?

lhdcqu 2003-12-07 10:02:36
我一个datawondow是连接两个数据表的,怎么实现对这两个数据表的插入数据啊?
请教各位!
...全文
66 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lhdcqu 2004-03-15
  • 打赏
  • 举报
回复
搞定了,
谢谢鹿门布衣,不过你老兄的方法漏了一点,修改成功了,必须还原表的修改属性!是吧?
parent.dw_2.accepttext()
Mcount = parent.dw_2.ModifiedCount() + parent.dw_2.DeletedCount()

if Mcount = 0 then //不必保存
return
else
li_ResultUpdate = parent.dw_2.Update(True,False)
if li_ResultUpdate = 1 then //成功保存编号表
//关掉对编号表的修改
parent.dw_2.Modify('cmganumber_cmganumid.Update = "No"')
parent.dw_2.Modify('cmganumber_cmganame.Update = "No"')
parent.dw_2.Modify('cmganumber_cmganumnote.Update = "No"')
//打开对成分表的修改
parent.dw_2.Modify('DataWindow.Table.UpdateTable = ~'CMgACompInfoCN~'')
parent.dw_2.Modify('cmgacompinfocn_cmganumid.Update = "YES"')
parent.dw_2.Modify('cmgacompinfocn_cmgaelementcn.Update = "YES"')
parent.dw_2.Modify('cmgacompinfocn_cmgastancn.Update = "YES"')
parent.dw_2.Modify('cmgacompinfocn_cmgacompnotecn.Update = "YES"')
parent.dw_2.Modify('cmgacompinfocn_cmganumid.KEY = "YES"')
//然后修改成分表
li_ResultUpdate = parent.dw_2.Update()
if li_ResultUpdate = 1 then
MessageBox("插入成功!","成功的将数据插入编号表和成分表!")
COMMIT USING SQLCA;
else
MessageBox("修改错误!","数据修改错误,错误代码"+string(SQLCA.sqlDBCode)+"~r~n错误原因:"+SQLCA.sqlERRTexT)
ROLLBACK USING SQLCA;
Beep(2)
end if
//编号表改为能修改状态
parent.dw_2.Modify('cmganumber_cmganumid.Update = "YES"')
parent.dw_2.Modify('cmganumber_cmganame.Update = "YES"')
parent.dw_2.Modify('cmganumber_cmganumnote.Update = "YES"')
parent.dw_2.Modify('cmganumber_cmganumid.KEY = "YES"')
parent.dw_2.Modify('DataWindow.Table.UpdateTable = ~'CMgANumber~'')
//取消成分表的能修改状态
parent.dw_2.Modify('cmgacompinfocn_cmganumid.Update = "NO"')
parent.dw_2.Modify('cmgacompinfocn_cmgaelementcn.Update = "NO"')
parent.dw_2.Modify('cmgacompinfocn_cmgastancn.Update = "NO"')
parent.dw_2.Modify('cmgacompinfocn_cmgacompnotecn.Update = "NO"')
parent.dw_2.Modify('cmgacompinfocn_cmganumid.KEY = "NO"')
else
MessageBox("Status", &
+ "Update of department table failed. " &
+ "Rolling back changes to CMgANumber.")
ROLLBACK USING SQLCA;
Beep(2)
end if
end if
jiazhuo 2003-12-08
  • 打赏
  • 举报
回复
up
lhuashang 2003-12-08
  • 打赏
  • 举报
回复
同意
就是修改数据窗口对象的 tableupdate 和 列的 update 属性
lmby 2003-12-07
  • 打赏
  • 举报
回复
integer rc

string err

/* The SELECT statement for the DataWindow is:

SELECT department.dept_id, department.dept_name,

employee.emp_id, employee.emp_fname,

employee.emp_lname FROM department, employee ;

*/

// Update department, as set up in the DW painter

rc = dw_1.Update(TRUE, FALSE)

IF rc = 1 THEN
//Turn off update for department columns.
dw_1.Modify("department_dept_name.Update = No")
dw_1.Modify("department_dept_id.Update = No")
dw_1.Modify("department_dept_id.Key = No")
// Make employee table updatable.
dw_1.Modify( &
"DataWindow.Table.UpdateTable = ~"employee~"")
//Turn on update for desired employee columns.
dw_1.Modify("employee_emp_id.Update = Yes")
dw_1.Modify("employee_emp_fname.Update = Yes")

dw_1.Modify("employee_emp_lname.Update = Yes")
dw_1.Modify("employee_emp_id.Key = Yes")
//Then update the employee table.
rc = dw_1.Update()
IF rc = 1 THEN
COMMIT USING SQLCA;
ELSE
ROLLBACK USING SQLCA;
MessageBox("Status", &
+ "Update of employee table failed. " &
+ "Rolling back all changes.")
END IF

ELSE
ROLLBACK USING SQLCA;
MessageBox("Status", &
+ "Update of department table failed. " &
+ "Rolling back changes to department.")

END IF

611

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder DataWindow
社区管理员
  • DataWindow社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧