DataGridView with relation(Show name, not id)

Go To



I have a problem regarding DataGridView. I need to show a Client_Name instead of Id_client This is the Product table and it has a relationship with the Clienttable.

IMAGE : enter image description here

I'm using Access DB and DataSet.

2012-04-04 16:54
by Hercko


In order to avoid having to do multiple queries to get the client name for each product you should include on your query an inner join to Clients table and return the client name along with the product data.

SELECT      pro.*, cli.[Name] as ClientName 
FROM        Products pro
INNER JOIN  Clients cli ON cli.Id = pro.ClientId

We could help more if you specify your data access strategy.

2012-04-04 17:00
by Claudio Redi
I using Access DB and DataSet, but how i create a binding with id and name - Hercko 2012-04-04 17:37
Not sure if I follow but if you do the query as I indicating you will already have the client name on your data set so you just need to bind it as you're doing for any other fiel - Claudio Redi 2012-04-04 17:39