CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Guest

    Can any body Help me !!! Creating Triggers in VB 6.0

    I need to create trigger on a table which should fire when any of the column is modified. I am using Visual Basic 6.0 as IDE and Access 8.0 as my database. MSDN online speaks about creating triggers but I am not aware how and where to create the triggers, I mean code window. Can someone helm me and tell me in detail how do I create triggers in VB using Data View Window or any other way.

    Thanks
    Gibli
    :-)






  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Can any body Help me !!! Creating Triggers in VB 6.0

    AFAIK triggers are a SQLServer "thing" only.
    thus, you need a client that can communicate to SQL Server. I suggest you use ISQL/w or Enterprise manager that comes with SQL server 6 and above.
    To create a trigger:
    CREATE TRIGGER mytrigger on yourtablename
    FOR INSERT, UPDATE
    AS
    ...write your SQLCode here


  3. #3
    Guest

    Re: Can any body Help me !!! Creating Triggers in VB 6.0

    Thanks for the response.

    I saw in MSDN library which talks about creating triggers in VB 6 for the Access database, they have shown the e.g. of NWIND.mdb. But the MSDN doesn't tell me where exactly I have to code this trigger. MSDN says you have to open Data View WIndow
    Database
    Tables
    Right click on the table you want to create a trigger but I didn't see any option available for me to create a trigger.


    Can anybody help me!!! The company where I am working presently is using MS-Access 8.0 as back-end amd VB6 as front-end. I can't use SQL server 6.0. I know that triggers can be implemented easily in SQL server 6 and oracle. But I am not aware how to implement triggers. I need the following feature :

    Whenever a user tries to update TABLE A, a record should be inserted in TABLE B
    which will tell me me what field in the TABLE A has be changed. How can I implement this functionality using VB6 and Access Database. I would appreciate it if somebody can explain it with an example.

    Thanks,
    Sri




  4. #4
    Join Date
    Apr 1999
    Location
    Michigan, USA
    Posts
    115

    Re: Can any body Help me !!! Creating Triggers in VB 6.0

    Triggers are not available in Access. You may be able to emulate triggers partially by using cascading updates/deletes. The rest has to be done inside your program with code and transactions.


  5. #5
    Join Date
    Nov 1999
    Location
    Italy
    Posts
    80

    Re: Can any body Help me !!! Creating Triggers in VB 6.0

    I think you can create a sub/function that writes records in table B, you can call this sub/function passing records changed everytime you code the update.
    I tried this to create a log file in access database, every operation calls a function that saves in a table the operation done. I'm sorry but i cant' write code now.


    private sub updatebutton_click()
    .
    .
    .
    ' here the code to update
    .
    .
    trigger (records_changed)
    end sub
    .
    .
    .
    .
    public sub trigger(records_changed as ....)
    .
    .
    .
    'here the code to write data in table B
    .
    .
    .

    end sub




    Something over there is coding....
    ... and you don't know!

  6. #6
    Guest

    Re: Can any body Help me !!! Creating Triggers in VB 6.0

    How will we know which field has been modified before updating? Is there any good solution for my problem. Can anybody put me in the right direction? I appreciate you people are trying to help. Give me example please!!!!!

    Thanks,
    Sri




  7. #7
    Join Date
    Nov 1999
    Location
    Italy
    Posts
    80

    Re: Can any body Help me !!! Creating Triggers in VB 6.0

    You can put a string equal to"" at beginning and everytime a textbox associated to a field changes it can set the string to a value, a.e.:


    private sub text1_change()
    'here you can also add code to test if already
    'changed, something like the function instr to
    'serach if mystring has 1

    mystring = mystring & "1"

    'it says the first field was changed so need
    'to be updated
    end sub




    In the update button you search in mystring what fields are changed.

    Something over there is coding....
    ... and you don't know!

  8. #8
    Join Date
    Dec 1999
    Posts
    5

    Re: Can any body Help me !!! Creating Triggers in VB 6.0

    I will try it out.

    Thanks,
    Gibli


  9. #9
    Guest

    Re: Can any body Help me !!! Creating Triggers in VB 6.0

    Thank you guy Lonely Wolf U have been very helpful.

    - Gibli


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured