我们可以在asp.net webapplication中实现sql触发器吗? [英] Can we implement sql triggers in asp.net webapplication?

查看:76
本文介绍了我们可以在asp.net webapplication中实现sql触发器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在asp.net webapplication中实现sql触发器(使用c#语言)吗?



如果是,请附上提供sql触发器示例的链接。

Can we implement sql triggers in asp.net webapplication (using c# language)?

if yes please attach the links which provides example on sql triggers.

推荐答案

是的,我们可以,但它是不推荐 [ ^ ],因为 sql注入 [ ^ ]以及其他一系列原因。使用 Sql存储过程 [ ^ ]。



请参阅:

演练:使用SqlDataSource Web调用存储过程服务器控制 [ ^ ]

演练:仅使用存储过程(C#) [ ^ ]
Yes, we can but it's not recommended[^], because of sql injection[^] and set of other reasons. Use Sql stored procedure[^] instead.

See:
Walkthrough: Calling a Stored Procedure Using the SqlDataSource Web Server Control[^]
Walkthrough: Using Only Stored Procedures (C#)[^]


1.触发器是一个SQL代码(与存储过程类似),当数据库服务器自动执行时da中发生了UPDATE,INSERT或DELETE操作与表关联的tabase表。



您可以在下一篇文章中看到详细信息和示例:触发器 - SQL Server [ ^ ]



2.ASP.NET Web应用程序角色是生成将由用户通过浏览器,因此Web应用程序应该专注于管理用户界面操作。



3.所以你不必混合使用这些部件。必须在数据库级别创建数据库触发器,然后将自动生成触发器以响应具有关联触发器的数据库表的数据库操作(INSERT,UPDATE或DELETE),无论是否将生成数据库操作作为响应来自Web应用程序或其他类型应用程序的用户请求。
1.A trigger is a SQL code (similar with stored procedure) that is automatically executed by the Database Server when an UPDATE, INSERT or DELETE operation occurred in the database table that is associated with the table.

You can see details and example in the next article: Triggers -- SQL Server[^]

2.ASP.NET web application role is to generate the web pages that will be used by the user via a browser, so the web application should be focused in managing the user interface actions.

3.So you don't have to not mix these tho parts. The database triggers have to be created at the database level, then the triggers will be automatically generated in response to the database operation (INSERT, UPDATE or DELETE) over database table that have associated triggers no matter if the database operation will be generated in response to the user request that are coming from a web application or other type of application.


这篇关于我们可以在asp.net webapplication中实现sql触发器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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