Does anyone know how to.....Come on Gurus step up to the plate!!!

Discussion in 'ASP.NET 2.0' started by easyrealtya, Jun 8, 2005.

  1. I have a details grid that inserts records for service requests into a database table.
    It is a Web Portal for a backdoor entry point for tenants to enter these requests into the sql database used by our software. The portal basically means that owners of our software do not have to surrender a user licence seat for each commercial tenant that is managed by the software.

    So anyway my grid inserts a wrko table record. The primary key is WRKOID. In our software when a Work Order is entered the system goes to a table called MRISEQ and get the next WRKOID by lookin for the seqid WRKOID and taking the lastused number related to that seqid and adding one. It then updates that lastused field by one. This happens for every Workorder entered.

    When I insert for the Portal I need the insertthat hits the WRKO table to alsoupdate that MRISEQ table after the grid fires that insert into WRKO.

    Is there code I can add to this source section...


    Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)





    Response.Redirect("/Your-Web-Portal/8page.aspx")





    End Sub


    as you see I already load another page when the insert button is hit on the grid.


    Can I force another sqldatasouce or objectdatasourceto run an update of that second table on the insert to WRKO.Or is it done another way??


    I am a rookie and have been able to take this ASP.Net 2.0 Visual Web developer tool and do some great things in just 3 weeks time. This is the last piece of the puzzle. Can anyone help!!


    PS I have learned to and tried to stick with all business layer objects in this as I read it was a better practice. I would like to go that way if possible.



    Post Edited (easyrealtya) : 6/8/2005 12:57:20 AM GMT
     
  2. Look into Triggers.





    You could create a trigger that will act upon changes that are made to another table.

    Ex:
    You need to update two tables WRKO and MRISEQ

    CREATE TRIGGER tPortalTrigger ON WRKO
    FOR INSERT
    AS
    UPDATE MRISEQ
    SET MyValue = MyNewValue
    WHERE Condition = Condition

    GO

    Hope this points you in the right direction.

    William O'Malley
     
  3. I was acyually able to embed an update statement in the same entry box as my insert statemet. So right after the "insert into WRKO" statement in the SQLDATASOURCE I just added the "Update MRISEQ set" and it works. That means you can actuallt run multiple types of queries for different table from that text input screen for the insertquery.THANKS!
     

Share This Page