Link to home
Start Free TrialLog in
Avatar of christos79
christos79

asked on

Refreshing Current Record ADO

Hi,

I have a grid connected to an ADO dataset. Then i select a record and i click on a button so that i do something with the details of that record. Is there a way to refresh the details only for Ā the selected record without using requery or another query to get them? Because I dont want to refresh lets say 1000 records, just to see the updated details of the one am really interested in.

Thanks in advance
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

Well if you update via the dataset you are using, the information will be refreshed on screen anyway.
If you are using a totally separate query object to do the updating then you will need to reload the dataset.
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or if you using clientdataset, there is special method to do it:

ClientDataSet1.RefreshRecord

ziolko.
Avatar of christos79
christos79

ASKER

ADOQuery1.Recordset.Resync(adAffectCurrent, adResyncAllValues);

i have the dataset in a datamodule. It gives me an error message for adAffectCurrent and adResyncAllValues. I have to put smth in the uses list?
you have to add ADOInt to uses clausule

ziolko.
insufficient key column information for updating or refreshing ...

Now i get this error message when i try to execute it. I tried to change the cursor type but nothing changes...
what database you use?

ziolko.
MS SQL Server 2005
run SQL profiler and call standard .Refresh then check with profiler what sql command has been executed, it's quite possible that not all records will be refetched but only changed ones

ziolko.
I am sorry but i didnt quite understand how this will help me fix the problem. I run SQL Profiler and saw the command. But i dont know why i get that error message in my application and how i can remove it.
call ADOQuery1.Refresh; and see into profiler if the complete select statement is executed or is there something in where clausule that limits output to only changed records

ziolko.
I get the same error message even with refresh <insufficient key column information for updating or refreshing>. So at the sql profiler i cannot see anything because refresh is not executed due to the error.
usual i use the requery-method of the associated dataset

meikl ;-)
if you got this errro it means that it's not possible to uniqually identify changed record, in this case you can try method suggested by meikl or call .Close then .Open on ADOQuery but I guess both methods will result with re-fetching all records

ziolko.
insufficient key column is probably because you do not have primary key (index) assigned).
I agree with Michael (Wellcome back Meikl !) - Requeery works miracles with ADO:
Do a primary key on some unique record and it will do the trick.Dont refresh as requery is much better.
also you should think about using sql access server components (msconnection instead of adoconnection).They actually do what you are trying to do.Really fantastic with sql server 2005.
you can have thousands of records but they get updated in a blink of an eye...