Link to home
Start Free TrialLog in
Avatar of ranhell
ranhellFlag for Mexico

asked on

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

Let's say I have these 2 tables

table1                                       table2
FName     LName   Status         Idstat      Desc
John        Smith         1                 1            ACTIVE
Mark        Doe            2                 2            INACTIVE

Then I aded a Datagrid into the form and bind it to the Table1 binding source and then
I tried to add a Query joining these 2 table and all field form Table1 and showing the Desc field from table2
and I got the "The schema returned by the new query differs from the base query error"
Now How do I get the Query to work on the grid, I've read that is better to build the datagrid programmatically instead of drag and drop into the form and assigned the query by code.

Avatar of malibuboats
malibuboats

The reason why you are getting that error is because you bind the grid to table and by doing so you confined the grid to useing table1's schema.  The query now returns one more field then table1 scheme had.

Instead of binding the table to the grid via the gui try calling the query from code and binding the grid there.

Example:
var query = table1.query1().ToList();
grid1.datasource = query;
grid1.databind();
the best way to go forward will be to bring correct data from the database and then bind that to the data grid

i will brind data like this and then bind it to the grid

select
    t1.FName,
    t1.LName,
    t2.Desc
From
    table1 t1
    Inner Join table2 t2 ON
        t1.Status = t2. IDStat
Avatar of ranhell

ASKER

Still not get it, could you be more expecific regarding to the code, I'd really appreciate it!!
i am assuming that you are binding your data grid with a data source and that data source is a table which you have filled in by calling the sql statement or a stored procedure
if that is the case then user my query to fetch the data as it will bring in the description column too which you want to show
you can find a lots of examples on the web for binding you data grid to the datatable
Avatar of ranhell

ASKER

I was expecting a code sample of what you said, can you provide one that resembles the scenario with the above tables.
ASKER CERTIFIED SOLUTION
Avatar of ranhell
ranhell
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial