从代码隐藏更新多个表?
问题描述:
我的数据库中有4个表.
我有一个允许插入/更新/删除的formview.我需要做的是在formview更新事件上,我需要使用在formview的文本框中键入一个值来更新其他3个表.这可能吗?以及如何获取文本框的值以传递给其他3个表?
在formview插入中,在所有4个表中插入一个ID,一个名称和一个产品ID.我想通了.我只需要更新名称. ID和产品ID将保持不变.
i have 4 tables in my database.
I have a formview that allows insert/update/delete. What i need to do is on formview updating event, i need to update 3 other tables with a value typed into the textbox on the formview. Is this possible? and how would i get the value of the textbox to pass to the other 3 tables?
the formview insert, inserts an id a name, and a product id into all 4 tables. i got that much figured out. i need only for the name to update. the id and product id will stay the same.
help?
答
使用事务,然后在其中执行多个更新查询,每次更新需要1个.
Use a transaction and then execute multiple update queries within it, 1 for each update required.
最佳方法要使用触发器.
http://msdn.microsoft.com/en-us/library/ms189799.aspx [ ^ ]
Best Way To Use Trigger.
http://msdn.microsoft.com/en-us/library/ms189799.aspx[^]