Solved

Refreshing Current Record ADO

Posted on 2008-10-20
16
1,317 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:christos79
  • 7
  • 5
  • 2
  • +2
16 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 22758159
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.
0
 
LVL 21

Accepted Solution

by:
ziolko earned 500 total points
ID: 22758227
try this:
ADOQuery1.Recordset.Resync(adAffectCurrent, adResyncAllValues);

should refresh current record

ziolko.
0
 
LVL 21

Expert Comment

by:ziolko
ID: 22758305
or if you using clientdataset, there is special method to do it:

ClientDataSet1.RefreshRecord

ziolko.
0
 

Author Comment

by:christos79
ID: 22758373
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?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 22758474
you have to add ADOInt to uses clausule

ziolko.
0
 

Author Comment

by:christos79
ID: 22758602
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...
0
 
LVL 21

Expert Comment

by:ziolko
ID: 22758830
what database you use?

ziolko.
0
 

Author Comment

by:christos79
ID: 22764847
MS SQL Server 2005
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 21

Expert Comment

by:ziolko
ID: 22764942
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.
0
 

Author Comment

by:christos79
ID: 22764980
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.
0
 
LVL 21

Expert Comment

by:ziolko
ID: 22765058
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.
0
 

Author Comment

by:christos79
ID: 22765089
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.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 22765123
usual i use the requery-method of the associated dataset

meikl ;-)
0
 
LVL 21

Expert Comment

by:ziolko
ID: 22765180
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.
0
 
LVL 22

Expert Comment

by:senad
ID: 23064109
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:
0
 
LVL 22

Expert Comment

by:senad
ID: 23064132
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...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
delphi custom sort exception 6 135
Delphi IDE crash without error message ... 7 75
Dev Express grid collapse 2 39
Adoquery sql  left join does not work 25 80
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now