Hi Tony,
the orderly way to refresh a ClientDataset is to close it and open again,  
also:

   ClientDataSet1.Close;
   ClientDataSet1.Open;

That's all!
Don't bore with the Query, MIDAS will do it automatically (and correctly)  
for you.

BTW: I think such technique are clearly represented in the User Manual and  
online-help. Why not take a look?

Viet Anh

On Sat, 26 May 2007 04:22:57 +0700, Tony1L <[EMAIL PROTECTED]> wrote:

> I have a project where I'm repeatedly calling a Button.Click event in
> which I'm using an ADOConnection to a MSSQL Database with Query and
> also open a ClientDataSet with corresponding DataSetProvider directed
> to the Query. Once it goes back through the code again ClientDataSet1
> isn't receiving any records...even through I see them by checking
>  Q1.RecordCount. On the second...third pass the ClientDataSet1
> is set to 0?  What could I add to this to properly refresh the dataset?
>
> Sample Code:
> procedure Tform1.button1Click(Sender: Tobject);
> Begin
> Q1.close;
> Q1.sql.clear;
> Q1.sql.add('select * from Table');
> Q1.open;
> Q1.RecordCount;
> ClientDataSet1.open;        //Dups Q1.Query DataSet
> Q1.close;  //Saving wear and tear on Server so running from Mem Buffer
> ClientDataSet1.RecordCount; //1st try works properly
>                             //later comes up empty even though
>                             //Q1.RecordCount has increased
>
> //Do Things with ClientDataSet1//
> ClientDataSet1.EmptyDataSet;
> ClientDataSet1.close;
> Form1.Button1.Click;  //Repeat until the cows come home
>
> //Tried removing the DataSet.close and adding ClientDataSet1.refresh
> with same empty result set after 1st pass?//
>
> Any suggestions on properly refreshing the ClientDataSet1?
>
> Thanks so much!
> Tony
>
>
>



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Reply via email to