BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TClientDataSet : refresh problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier)
View previous topic :: View next topic  
Author Message
Sylvain
Guest





PostPosted: Wed Jul 09, 2003 11:05 am    Post subject: TClientDataSet : refresh problem Reply with quote



Hi,

I use a TClientDataSet and use it to insert data to the DB :
cdsServices.Insert;
cdsServices.FieldValues['Nom'] := nomService;
cdsServices.Post;
cdsServices.ApplyUpdates(-1);

In my table, I have a AutoNumber field and want to get it value. For that
I have to do a :
cdsServices.Refresh;

The problem is that after having done that refresh, all modifications
(insert, delete, ...) done on the ClientDataSet disappaear wherease they are
well in the DB. And if I restart tha application, I can see the
modifications.

Thanks if you have any idea about how to resolve my problem.

Sylvain.


Back to top
Sylvain
Guest





PostPosted: Wed Jul 09, 2003 3:52 pm    Post subject: Fixed Reply with quote



The reason was that, in the server, I opened the Table object (it could be
the case if tou define it as Active, or when, like me, you do it dynamicly
and call the Open procedure). In that case, the server create a recordset
when the client connect itself, and when it calls a Refresh, the server send
that recordset, et not data from the DB.


"Sylvain" <lecornes (AT) enseirb (DOT) fr> a écrit dans le message de news:
3f0bf6dc$0$10857$626a54ce (AT) news (DOT) free.fr...
Quote:
Hi,

I use a TClientDataSet and use it to insert data to the DB :
cdsServices.Insert;
cdsServices.FieldValues['Nom'] := nomService;
cdsServices.Post;
cdsServices.ApplyUpdates(-1);

In my table, I have a AutoNumber field and want to get it value. For
that
I have to do a :
cdsServices.Refresh;

The problem is that after having done that refresh, all modifications
(insert, delete, ...) done on the ClientDataSet disappaear wherease they
are
well in the DB. And if I restart tha application, I can see the
modifications.

Thanks if you have any idea about how to resolve my problem.

Sylvain.





Back to top
Manho Joo
Guest





PostPosted: Mon Jul 21, 2003 7:21 am    Post subject: Re: TClientDataSet : refresh problem Reply with quote



"Sylvain" <lecornes (AT) enseirb (DOT) fr> wrote

Quote:
Hi,

I use a TClientDataSet and use it to insert data to the DB :
cdsServices.Insert;
cdsServices.FieldValues['Nom'] := nomService;
cdsServices.Post;
cdsServices.ApplyUpdates(-1);

In my table, I have a AutoNumber field and want to get it value. For that
I have to do a :
cdsServices.Refresh;

The problem is that after having done that refresh, all modifications
(insert, delete, ...) done on the ClientDataSet disappaear wherease they are
well in the DB. And if I restart tha application, I can see the
modifications.

Thanks if you have any idea about how to resolve my problem.

Sylvain.

try to do like below..

cdsServices.Insert;
cdsServices.FieldValues['Nom'] := nomService;
cdsServices.Post;
cdsServices.ApplyUpdates(0);
cdsServices.Refresh;

AutoInc is hard to dealing.
I used dbexpress and mysql, terreble... -_-;;
try use time-stamp based ID.
below code let 12 chars ID based on local date,time.

function TDM.GetNewID: string;
var
DelIndex : integer;
aStr : string;
begin
aStr := Format('%-15s',[FloatToStr(Now)]);
aStr := StringReplace(aStr,' ','0',[rfReplaceAll]);
DelIndex := Pos('.',aStr);
Delete(aStr,DelIndex,1);
Delete(aStr,1,2);
Delete(aStr,13,1);
result := aStr;
end;

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.