JanT
JanT

Reputation: 2096

Populate datagrid from two tables (VB.NET / Access)

I have Access database and I'm using VB.NET. DB has two tables

  1. Technicians
  2. Faults

I have columns I want from technicians table in datagrid, but I want to have extra column which should show how many faults every technician fixed based on the Faults table(so I think query will need to run for every row). Is this even possible?

Big Thank you for any help

Upvotes: 1

Views: 823

Answers (2)

BSergei
BSergei

Reputation: 21

You will need to specify which columns you want to add in the form's Load() method and enable autogenerate columns property for gridview to true.

Upvotes: 1

codingbiz
codingbiz

Reputation: 26386

That should be

SELECT technicians.techname, count(*) AS NoOfFaults
FROM technicians
LEFT JOIN faults ON technicians.ID = faults.TechnicianID
GROUP BY technicians.techname;

Upvotes: 1

Related Questions