datagrid to handle JOINed tables with the same column names

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???
 
B

bruce barker

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)
 
M

Max

Thank you that works perfectly! I think the next time I design my database
I'll use unique column names though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top