datagrid to handle JOINed tables with the same column names

  • Thread starter Thread starter Max
  • Start date Start date
M

Max

I've got a datagrid that binds a query that joins three tables and I need to
specify the "title" field which is the same column name in two of the
tables.

I thought this would work, but the datagrid is coming up blank:
....
<asp:BoundColumn DataField="products.title" HeaderText="Item">
</asp:BoundColumn>
<asp:BoundColumn DataField="categories.title" HeaderText="Category">
</asp:BoundColumn>
....
I'd rather not change the database schema.

Any hints???
 
the sql queries do not return the table name with the column names, so they
both have the same name. they are only distinguished by the numeric index.
you do not have to change the schema, to change the returned columns names,
you can do that in the select

select t.name as name1, t2.name as name2
from t
jon t2 ...

-- bruce (sqlwork.com)
 
Thank you that works perfectly! I think the next time I design my database
I'll use unique column names though.
 
Back
Top