如何使用C#中的一个公共列更新多个表 [英] how to update multiple tables with one common column in C#

查看:57
本文介绍了如何使用C#中的一个公共列更新多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#中的一个公共列更新多个表#



i有一个带有systeminfo的表,它使用userid将系统数据插入一行。

i有一个带有ServiceInfo的anther表,它在另一个表中插入了Services。

但现在我想在更新SystemInfo表时更新表中的所有服务。
两个
表UserId很常见。



但我不知道如何更新服务。





任何人都可以帮我解决这个问题。





谢谢和问候

Sam .198979

how to update multiple tables with one common column in C#

i have one table with systeminfo which inserts system data in one row with userid.
i have anther table with ServiceInfo which inserts Services in another table.
but now i want to update all services in table when it's updates the SystemInfo table.
in both tables UserId is common.

but am not getting idea how to update the services .


can anyone help me solving this query.


Thanks & Regards
Sam.198979

推荐答案

我想你的意思是,尽管SystemInfo表插入了一些值(userId),或者你应该将Serviceinfo的相应UserId值插入到另一个表中。



是的,你可以用触发器来做。



如果是MS SQL Server ......



请参阅此MSDN页面 -

创建触发器 [ ^ ]



以此作为虚拟示例 -



SQL Fiddle [ ^ ]





问候,
i guess you mean as soon SystemInfo table has some values (userId) inserted or Updated you should insert the respective UserId values of Serviceinfo to your "another table".

yes you can do it with triggers.

If it's MS SQL Server...

Refer this MSDN page-
Creation of Triggers[^]

take this as dummy example-

SQL Fiddle [^]


Regards,


这篇关于如何使用C#中的一个公共列更新多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆