[Solved] DBgrid not showing changes and show error when to try update – Insufficient key column information for updating or refreshing [closed]


My guess is that:

does not have the recent changes

is because the data has not been posted. And cannot be from what I can see. You’re trying to insert and update tuples from two tables, but you fetched only a foreign key of a detail table. Imagine, that you’d like to update this resultset (even manually by some SQL command tool):

SELECT
   Customer.Name,
   CustomerCar.CusID,
   CustomerCar.Car
FROM
   Customer, CustomerCar
WHERE
   Customer.CusID = CustomerCar.CusID

You could update CustomerCar table:

UPDATE CustomerCar SET Car="NewValue" WHERE CusID = <Fetched CustomerCar.CusID>

because you fetched its unique foreign key in the CustomerCar.CusID column, whilst you couldn’t update Customer table:

UPDATE Customer SET Name="NewValue" WHERE <What?>

because you didn’t fetch any unique primary key. And at the same situation is the engine, I guess. I only guess, but I don’t believe that there are fetched any metadata for the WHERE clause (which is the only place where you could get the unique primary key for the Customer table). Yes, you could cheat with an SQL command tool and use the key fetched for the other table, but client engines are not that smart, I must add.

You received this error:

Insufficient key column information for updating or refreshing

because ADO doesn’t know which record should update (or refresh) because of the missing unique identifier for both tables (primary unique keys you missed to fetch).

My advice for possible solution is simple, just fetch primary unique keys for both tables (CusCarID is a made up primary unique key of the CustomerCar table):

SELECT
   Customer.CusID,
   Customer.Name,
   CustomerCar.CusCarID,
   CustomerCar.Car
FROM
   Customer, CustomerCar
WHERE
   Customer.CusID = CustomerCar.CusID

6

solved DBgrid not showing changes and show error when to try update – Insufficient key column information for updating or refreshing [closed]