CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2001
    Posts
    4

    Update same field in multiple table

    I need to design an database which has five tables. I would appreciate if anyone can let me know how to perform this function:
    when I click on update in one table, the same field which also locates on other table has to be updated as well... how do I do that ?
    Please help !!!!!

    THANK YOU !!!!


  2. #2
    Join Date
    Sep 2001
    Location
    Little Rock, Arkansas
    Posts
    40

    Re: Update same field in multiple table

    Two observations:

    1. The best method to do this may depend on which database you are using. Does your database have triggers?

    2. If you have a field that needs to stay synchronized across five different tables, then your database is not normalized. The solution may be a better database design. My gut feeling is a database that has this design will be a problem to maintain.


  3. #3
    Join Date
    Sep 2001
    Posts
    4

    Re: Update same field in multiple table

    Thank you for your advice. My database has five forms which one primary key can be a secondary key to another form. This is supposed to be my assignment and I have to no way to alter the design coz I just open the database with the VisData Add-In and has to think about how to update the record in different tables on my own.
    I am a real beginner, so I don't know what is a 'trigger'.
    Thank you anyway.


  4. #4
    Join Date
    Sep 2001
    Location
    Little Rock, Arkansas
    Posts
    40

    Re: Update same field in multiple table

    In some databases (SQL Server, Oracle, DB2, etc.) you can specify a piece of code called a trigger that will run whenever an specific event (insert, update, delete, select) happens to a table. You would write an update trigger for each table that would update the other four tables each time a record was changed.

    As to your original problem, whenever any one of the tables is updated I would just go ahead and submit an update query against the other four tables for the one field you want to keep in sync.


  5. #5
    Join Date
    Sep 2001
    Posts
    2

    Re: Update same field in multiple table

    i can suggest you a way .ido not know if this is suitable but it works.
    what you do is dim ado.recordsets and connect to those databases and update the fields you disire by update statements.



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