dcsimg
Results 1 to 2 of 2

Thread: Help showing data on a datagrid from one table based on the value of another one

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    7

    Post Help showing data on a datagrid from one table based on the value of another one

    ok guys i'll try to be as thorough as possible in explaining my problem.

    I have a form with a data-set and a datagrid, the data-set contains information from 3 different tables and has relationship in place for those 3 tables, these 3 tables are comprise as follows:
    table 1 has the following fields:ProjectID, CustomerID, DateStarted, DateClosed, IsClosed, ClosedBy
    Table2 has the following fields: VehicleAssignmentID, ProjectID, VehicleID
    table3 has the following fields: TaskAssignmentID,ProjectID, VehicleAssignmentID,TaskID, TeamID, EmployeeID,TaskNotes, IsTaskClose

    the goal is to show on one of the data-grids information related to table 2, which leads us to table 4 which has VehicleID along with other vehicle information, so the main idea is: based on table 2 VehicledID show on the data-grid all the information of table 4 while keeping everything in sync.

    now why isn't table 4 on the data-set and related as the other 3 tables? well i'm using typed datasets with table adapters and like to keep all the automatically generated CRUD, when i add vehicle table it does not generate all the CRUD commands. only READ or SELECT command is created.

    Can anyone share some light on how to approach this. all ideas welcome

    thanks

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,787

    Re: Help showing data on a datagrid from one table based on the value of another one

    There's no good reason to not modify a typed DataSet if that's what the situation requires. The designer provides the facility to do that for a reason.

    Any automatic SQL code generation requires information to work on. In order for UPDATE and DELETE statements to be generated, the system needs to be able to uniquely identify the record to be updated or deleted and for that it uses the primary key of the table. If your table has no primary key then those statements cannot be generated and that is the most common reason that they aren't.

    An INSERT statement doesn't depend on a primary key so they will usually still be generated. The usual reason for no INSERT statement being generated is that the query includes multiple tables. If that's not the case in your app then I'm not sure what happened but if something went wrong on that table, it might not be a bad idea to delete it and then re-run the wizard to add it back again.

    Regardless, you can always add missing commands yourself and sometimes that is required for perfectly legitimate reasons. You can also add queries, tables and table adapters and should do if the situation requires it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width