Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Trigger in asp.net

Trigger in asp.net

Scheduled Pinned Locked Moved ASP.NET
databasehelpcsharpasp-netsql-server
17 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sheemap
    wrote on last edited by
    #1

    hiiiiiii to al one canl any one can hep me that i wanted to set trigger in asp.net web page by sql server how to call that trigger in web page please help me to sort out this problem

    rizvan sivally

    P P N 3 Replies Last reply
    0
    • S sheemap

      hiiiiiii to al one canl any one can hep me that i wanted to set trigger in asp.net web page by sql server how to call that trigger in web page please help me to sort out this problem

      rizvan sivally

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      As per my knowledge Trigger is execute itself based on DML and DML. So you can not call explicitly. http://msdn.microsoft.com/en-us/library/ms189799.aspx[^]

      Parwej Ahamad

      S 2 Replies Last reply
      0
      • P Parwej Ahamad

        As per my knowledge Trigger is execute itself based on DML and DML. So you can not call explicitly. http://msdn.microsoft.com/en-us/library/ms189799.aspx[^]

        Parwej Ahamad

        S Offline
        S Offline
        sheemap
        wrote on last edited by
        #3

        as we call stored procedure in asp.net page same as how we call any trigger of sql in asp.net page i created trigger but wanted to use that in application Thanks for prompt reply

        rizvan sivally

        P 1 Reply Last reply
        0
        • S sheemap

          as we call stored procedure in asp.net page same as how we call any trigger of sql in asp.net page i created trigger but wanted to use that in application Thanks for prompt reply

          rizvan sivally

          P Offline
          P Offline
          Parwej Ahamad
          wrote on last edited by
          #4

          Dear I already said you can not call Trigger explicitly. Have you read provided link? Better to ask question you must read first about Triggers how it works and why it's required

          Parwej Ahamad

          1 Reply Last reply
          0
          • P Parwej Ahamad

            As per my knowledge Trigger is execute itself based on DML and DML. So you can not call explicitly. http://msdn.microsoft.com/en-us/library/ms189799.aspx[^]

            Parwej Ahamad

            S Offline
            S Offline
            sheemap
            wrote on last edited by
            #5

            my question is that how to use the trigger in asp.net application meaning that path or connection string or any query to execute the trigger in web application

            rizvan sivally

            R 1 Reply Last reply
            0
            • S sheemap

              my question is that how to use the trigger in asp.net application meaning that path or connection string or any query to execute the trigger in web application

              rizvan sivally

              R Offline
              R Offline
              Rizwan Bashir
              wrote on last edited by
              #6

              which type of trigger this is ? Lets say it is on update then update any record when you want it triggered

              Rizwan Bashir <a href="http://www.alm-soft.com/">ALM Soft</a>[<a href="http://www.alm-soft.com/" target="_blank" title="New Window">^</a>]

              S 1 Reply Last reply
              0
              • R Rizwan Bashir

                which type of trigger this is ? Lets say it is on update then update any record when you want it triggered

                Rizwan Bashir <a href="http://www.alm-soft.com/">ALM Soft</a>[<a href="http://www.alm-soft.com/" target="_blank" title="New Window">^</a>]

                S Offline
                S Offline
                sheemap
                wrote on last edited by
                #7

                Sir i created trigger(insert,update,delete) as we can call stored procedure(insert,update,delete table) but the question is how we use this trigger in web application as we created in sql server to fire them.

                rizvan sivally

                R T P 3 Replies Last reply
                0
                • S sheemap

                  Sir i created trigger(insert,update,delete) as we can call stored procedure(insert,update,delete table) but the question is how we use this trigger in web application as we created in sql server to fire them.

                  rizvan sivally

                  R Offline
                  R Offline
                  Rizwan Bashir
                  wrote on last edited by
                  #8

                  so your triggers are not Database oriented, basically a code in asp.net is required to be run lets say every one hour , if it is so then use Timer which will be run on background and wont require any one to browse the page to trigger it like window service. check this for timer ( the last post on this page)http://forums.asp.net/t/1187287.aspx/1[^]

                  Rizwan Bashir <a href="http://www.alm-soft.com/">ALM Soft</a>[<a href="http://www.alm-soft.com/" target="_blank" title="New Window">^</a>]

                  1 Reply Last reply
                  0
                  • S sheemap

                    Sir i created trigger(insert,update,delete) as we can call stored procedure(insert,update,delete table) but the question is how we use this trigger in web application as we created in sql server to fire them.

                    rizvan sivally

                    T Offline
                    T Offline
                    Tech Code Freak
                    wrote on last edited by
                    #9

                    As the name suggests - 'Trigger', these triggers are automatically fired. And according to my knowledge, one cannot fire the trigger explicitly. That means, they get automatically fired when the task for which they have been made occurs. i.e. when some data is inserted / updated / deleted in the table. For eg. If you have made an insert trigger on a table, it will be fired only when some data is inserted in it..and so on. You don't have to call / fire these triggers in your code.

                    1 Reply Last reply
                    0
                    • S sheemap

                      hiiiiiii to al one canl any one can hep me that i wanted to set trigger in asp.net web page by sql server how to call that trigger in web page please help me to sort out this problem

                      rizvan sivally

                      P Offline
                      P Offline
                      Pravin Patil Mumbai
                      wrote on last edited by
                      #10

                      You first need to understand the trigger. Here is a brief explanation : Trigger is native to SQL and not to ASP.NET. Trigger is a code segment in SQL that gets executed when a specified condition is met. There are three types of trigger Inser, Update, Delete trigger. Insert Trigger will be executed when you insert a new row into the table. Same applies to update and delete trigger. So with this much explanation you must be clear that Trigger is the thing that is not called explicitly, rather SQL server will automatically execute your trigger when you insert, update or delete any record from the table. Coming back to your question : As you said, you know how to call a stored procedure, so call it as you do. Write a trigger on your desired table for a insert/update/delete operation. When the specified operation is performed in the Stored Procedure, trigger will be automatically fired by SQL. Important : Trigger is in SQL and not ASP.NET. Trigger can not be executed explicitly as you do Stored Procedure. Trigger is taken care by SQL server. For further reference : How to Write Trigger 1. http://msdn.microsoft.com/en-us/library/ms189799.aspx[^] 2. http://www.sqlservercentral.com/Forums/Topic351362-92-1.aspx[^] 3. http://download.oracle.com/docs/cd/B12037_01/server.101/b10759/statements_7004.htm[^] How Trigger Works 1. http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookTextView/47865;pt=47764[^] 2. http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/triggers.htm[

                      S 1 Reply Last reply
                      0
                      • S sheemap

                        Sir i created trigger(insert,update,delete) as we can call stored procedure(insert,update,delete table) but the question is how we use this trigger in web application as we created in sql server to fire them.

                        rizvan sivally

                        P Offline
                        P Offline
                        Pravin Patil Mumbai
                        wrote on last edited by
                        #11

                        You do not need to use the triggers through ASP.Net. They will be automatically fired by SQL.

                        I quit being afraid when my first venture failed and the sky didn't fall down.

                        S 1 Reply Last reply
                        0
                        • P Pravin Patil Mumbai

                          You first need to understand the trigger. Here is a brief explanation : Trigger is native to SQL and not to ASP.NET. Trigger is a code segment in SQL that gets executed when a specified condition is met. There are three types of trigger Inser, Update, Delete trigger. Insert Trigger will be executed when you insert a new row into the table. Same applies to update and delete trigger. So with this much explanation you must be clear that Trigger is the thing that is not called explicitly, rather SQL server will automatically execute your trigger when you insert, update or delete any record from the table. Coming back to your question : As you said, you know how to call a stored procedure, so call it as you do. Write a trigger on your desired table for a insert/update/delete operation. When the specified operation is performed in the Stored Procedure, trigger will be automatically fired by SQL. Important : Trigger is in SQL and not ASP.NET. Trigger can not be executed explicitly as you do Stored Procedure. Trigger is taken care by SQL server. For further reference : How to Write Trigger 1. http://msdn.microsoft.com/en-us/library/ms189799.aspx[^] 2. http://www.sqlservercentral.com/Forums/Topic351362-92-1.aspx[^] 3. http://download.oracle.com/docs/cd/B12037_01/server.101/b10759/statements_7004.htm[^] How Trigger Works 1. http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookTextView/47865;pt=47764[^] 2. http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/triggers.htm[

                          S Offline
                          S Offline
                          sheemap
                          wrote on last edited by
                          #12

                          Thanks alot sir as we know what ever we put the message in the trigger it will show after action is fired in database. now question is that is trigger also restrict any data to insert,delete or update in database as well as for webapplication Thnaking you again

                          rizvan sivally

                          P 1 Reply Last reply
                          0
                          • P Pravin Patil Mumbai

                            You do not need to use the triggers through ASP.Net. They will be automatically fired by SQL.

                            I quit being afraid when my first venture failed and the sky didn't fall down.

                            S Offline
                            S Offline
                            sheemap
                            wrote on last edited by
                            #13

                            the next question is that is that possible to restrict to insert,update and delete data by trigger in the database and in web application if possible then what will be query of the trigger

                            rizvan sivally

                            T 1 Reply Last reply
                            0
                            • S sheemap

                              the next question is that is that possible to restrict to insert,update and delete data by trigger in the database and in web application if possible then what will be query of the trigger

                              rizvan sivally

                              T Offline
                              T Offline
                              Tech Code Freak
                              wrote on last edited by
                              #14

                              Yes, It is possible to restrict DML by triggers. You said that you have already made triggers. Then you only have to edit them and add your logic for restricting some action. It must be in if-else construct. If the action is not valid according to your logic, then just add 'Rollback Transaction' in your if construct! And you're done! You have just restricted the invalid DML! Enjoy! For further details, Visit this[^]

                              S 1 Reply Last reply
                              0
                              • T Tech Code Freak

                                Yes, It is possible to restrict DML by triggers. You said that you have already made triggers. Then you only have to edit them and add your logic for restricting some action. It must be in if-else construct. If the action is not valid according to your logic, then just add 'Rollback Transaction' in your if construct! And you're done! You have just restricted the invalid DML! Enjoy! For further details, Visit this[^]

                                S Offline
                                S Offline
                                sheemap
                                wrote on last edited by
                                #15

                                Thanking you

                                1 Reply Last reply
                                0
                                • S sheemap

                                  Thanks alot sir as we know what ever we put the message in the trigger it will show after action is fired in database. now question is that is trigger also restrict any data to insert,delete or update in database as well as for webapplication Thnaking you again

                                  rizvan sivally

                                  P Offline
                                  P Offline
                                  Pravin Patil Mumbai
                                  wrote on last edited by
                                  #16

                                  Yes for sure, if you do not want any invalid to insert in the database then also you can use the trigger. But again there are two options to do so.. Option 1: Use the Constraints 1. http://dev.mysql.com/doc/refman/5.0/en/constraint-invalid-data.html[^] 2. http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/general005.htm[^] 3. http://odetocode.com/articles/79.aspx[^] Option 2: Use Trigger 1. http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookTextView/48841;pt=48327/*[^] 2. Just do the rollback in the trigger to restrict the data Maintain data integrity: http://ss64.com/ora/syntax-constraints.html[^] I would recommend you using the first approach, because Triggers are not that easy when it comes to maintainance of the project. Hope this helps. All the best.

                                  I quit being afraid when my first venture failed and the sky didn't fall down.

                                  1 Reply Last reply
                                  0
                                  • S sheemap

                                    hiiiiiii to al one canl any one can hep me that i wanted to set trigger in asp.net web page by sql server how to call that trigger in web page please help me to sort out this problem

                                    rizvan sivally

                                    N Offline
                                    N Offline
                                    NikulDarji
                                    wrote on last edited by
                                    #17

                                    [] May this link helps you.... :)

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups