473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Using Database triggers in a .net application

Hello,

this is swapna.

I dont know about calling trigger into .net procedure.
i create the trigger in sqlserver.after how to call the trigger into .net application

Please help me
how to do this.i need any example with .net application

please send me as soon as possible
Apr 3 '08 #1
4 2013
Shashi Sadasivan
1,435 Expert 1GB
A trigger in a database is activated when any change to the database occours, depends on if you have set it to update, delete or insert of any row and condition.

This is a very database specific trigger and is called automatically when there is an appropriate change made to a database
Apr 3 '08 #2
hai all,

iam swapna.i have one doubt in asp.net.

how to use the triggers in .net application.how to call the triggers.I need the code.please help me as soon as possible.
Apr 4 '08 #3
Plater
7,872 Expert 4TB
I have merged (and renamed) these threads. In the future, please refrain from double posting. See the Posting Guidelines for more information.

MODERATOR
Apr 4 '08 #4
balabaster
797 Expert 512MB
How to use the triggers in .net application.how to call the triggers.I need the code.please help me as soon as possible.
You don't call a trigger from .NET....or any other programming language. Once you've written a trigger on your server, it's autonomous - that is - it runs itself.

Lets consider the following example:

Expand|Select|Wrap|Line Numbers
  1. Create Trigger dbo.SetUserActive On dbo.Users
  2. For Insert
  3. As
  4. Begin
  5.  
  6.   /* Prevent calling applications getting erroneous notifications causing   queries to incorrectly appear to fail by setting the NoCount parameter. */
  7.   Set NoCount On
  8.  
  9.   Declare @Key int
  10.  
  11.   Select @Key = User_PKey
  12.   From inserted
  13.  
  14.   Update dbo.Users
  15.   Set User_Active = 1
  16.   Where User_PKey = @Key
  17.  
  18.   Set NoCount Off
  19.  
  20. End
When I apply this trigger to my table, any time I insert a row into my Users table, the column User_Active will be set to 0, regardless of what I set it to in the insert query.

There is no way to call this trigger from code or from another query. It is attached to the Users table and runs autonomously. Hence, you can't call it from .NET or any other programming language. If you wish to have a function that you can call from .NET, then you need to look at Stored Procedures or User Defined Functions.
Apr 4 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Ruby Tuesdays | last post by:
Perhaps you database guru able to suggest what would be a good choice for opensource database platform to use to develop projects. At the moment the project is small/medium, but it will grow in...
23
by: ajikoe | last post by:
Hello I need to build table which need searching data which needs more power then dictionary or list in python, can anyone help me what kind of database suitable for python light and easy to learn....
7
by: Sjaak van Esdonk | last post by:
Hi all, i'm trying to find a solution for the following problem: I have two different database called A and B. On database A runs an application call AA. Some information from the database A...
3
by: serge | last post by:
I have all the scrips to create a database. I have a few questions: 1- I am creating a batch file that it will call many lines like: db2 -td@ -f filename.sql -z output.txt The order i am using...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
1
by: Ted | last post by:
I managed to get it installed OK, along side MS Visual Studio 2005 (with which I received it). During the install, I made sure I installed everything. I have developed a number of applications...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
2
by: celerno | last post by:
Hi all, first some history: i'm developing an application who access foxpro databases using VfpOledb provider... but this cause a headache when i delete rows cause some tables call triggers... to...
12
by: nyathancha | last post by:
Hi, I have a question regarding best practices in database design. In a relational database, is it wise/necessary to sometimes create tables that are not related to other tables through a...
3
by: | last post by:
Hi - I can update a second field based on update of the the first field of the same table. It works fine in the Enterprise Manager (EM), but I can't seem to make the trigger fire when I alter the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.