Problem with Add Query RRS feed

  • Question


    I added Pubs to vb 2008 project.

    Draged the authors into the Form1.

    Add Query....


    SELECT     authors.au_lname, authors.au_fname, titles.title, titles.price
    FROM         authors INNER JOIN
                          titleauthor ON authors.au_id = titleauthor.au_id INNER JOIN
                          titles ON titleauthor.title_id = titles.title_id



    Now when I press OK --->

    "The schema returned by the new query differs from the base query"


    But it works at Execute Query!


    I don't know what's the problem.


    How am I suppose to Join columns from different tables?

    Wednesday, November 12, 2008 8:11 AM

All replies

  • Hi


    When you want to show the columns from diffrent Tables you can join them and use Anonymous Types for projecting data.


    DataclassesDataContext db = new DataclassesDataContext();


    var query =

    from t1 in db.Tables1

    from t2 in db.Tables2

    from t3 in db.Tables3

    where t1.ID == t2.Table1ID && t2.ID == t3.Table2ID

    select new


    OrderCode = t1.Code,

    ItemID = t2.ItemID,

    FiscalTitle = t3.Title



    and for your query it is something like this:


    var query =

    from a in db.authors

    from b in db.titleauthor

    from c in db.titles

    where a.au_id == b.au_id && b.title_id == c.title_id

    select new


    Iname = a.au_lname,

    fname = a.au_fname,

    title = c.title,

    price = c.price


    Saturday, November 15, 2008 4:18 AM