Query Question RRS feed

  • Question


    I am new to LINQ so I have what is probably a basic question. I have filled 2 datasets:


    Dim DB2SQLData As New db2SQLDataSet()

    Dim sheet2Adapter As New db2SQLDataSetTableAdapters.Sheet2TableAdapter

    Dim noteAdapter As New db2SQLDataSetTableAdapters.NotesTableAdapter




    The sheet2 table has a one to many relation to the notes table.

    I have dragged over the details of sheet2 on to a form and can query result to fill it:


    Dim sheet2 = From sheet1 In DB2SQLData.Sheet2 _

    Where sheet1("Engr") IsNot DBNull.Value _

    Select sheet1


    I have also dragged the datagrid version of notes on to the same form.

    What I would like to do is have the datagrid show all the notes related to the current sheet2 id.


    Any hlep would be greatly appreciated.

    Let me know if any more info is needed.


    Thursday, June 19, 2008 4:20 PM

All replies


    Code Snippet

    Dim qry = _

    From sheet In DB2SQLData.Sheet2 _

    Join note In DB2SQLData.Notes On sheet.Sheet2ID Equals note.Sheet2ID _

    Where Not sheet.IsEngrNull() _

    Select New With {note.Note}


    DataGridView1.DataSource = qry.ToList()


    Sunday, June 22, 2008 10:19 PM
  • Thaks very much for the reply. While I get no errors with this code, the notes datagrid does not fill at all.

    When I use the:




    only(no query statements), the grid puts the corresponding notes to sheet2 in the grid.

    But I need to querry sheet2 differently depending on the situation, so I always need corresponding notes to the sheet2 records that I have queried to always show in the grid.


    2 things:

    1. The notes table for the grid shows under the sheet2 table in the Data Sources window. ( since I made that many to one relationship in the designer. I just want to make sure you know which table is used.


    2. Do you know where I can find a good resource for LINQ to datasets? I found some and ado books and other stuff but they barely touch on the basics.


    Thanks so much for the help!

    Suggestions from anyone else would be appreciated.


    Monday, June 23, 2008 1:26 PM