ranhell
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.
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.
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
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
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
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
ASKER
I was expecting a code sample of what you said, can you provide one that resembles the scenario with the above tables.
follow this sample you can do it on your own
http://www.codeproject.com/KB/aspnet/DataGridView__GridView.aspx
http://www.codeproject.com/KB/aspnet/DataGridView__GridView.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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();