Home > Back-end >  Clientdateset how to update
Clientdateset how to update

Time:10-19

ClientDataSetT1. Close;
ClientDataSetT1. Append;
ClientDataSetT1.Com mandText:='update T_message set num=10 where carid=' "+ LabeledEdit10. Text +" '"';
ClientDataSetT1. Post;
ClientDataSetT1. Open;
ClientDataSetT1. ApplyUpdates (1);

How do I, how to use Cilentdataset database updates! This method error, said clientdateset close! ~

CodePudding user response:

I am directly using the execute

ClientDataSetT1. Close;
//ClientDataSetT1. Append;
ClientDataSetT1.Com mandText:='update T_message set num=10 where carid=' "+ LabeledEdit10. Text +" '"';
{ ClientDataSetT1. Post;
ClientDataSetT1. Open;
ClientDataSetT1. ApplyUpdates (1); }
ClientDataSetT1. Execute;

CodePudding user response:

This is a problem of hundred years ago, now also will ask someone in

Cds.Com mandText:=' ';
The corresponding is
CDS. The Execute;
At this moment what it is not necessary to perform the open and close operation, as long as you have datasetprovider can perform, of course, there are options in datasetprovider (poAllowCommandText) command to be executed to allow text

Commandtext is bad, not safe way, should avoid to use SQL in three layers on the client side

The right way is
CDS, append ();
CDS. FieldByName ('). Asxxx:=XXX;
.
CDS, Post ();
CDS, ApplyUpdates (1);

Can update to the database, in which the corresponding update in DataSetProvider UpdateMode property, is also the problem of hundred years ago, due to 3 kinds of ways, simply is the update SQL statement WHERE the content of the

. UpWhereKeyOnly
Only use the specified key resides in the WHERE
This is in the Provider. The DataSet on the side of the field added ProviderFlags pfInKey

. UpWhereChanged
Key is specified in the WHERE, and have altered fields will also be put in the WHERE

. UpWhereAll
All the fields will be placed in the WHERE

UpdateMode is a very important attribute, it often are introduced, and the teaching, improve the books ignore, it guarantees the reliability of data
. The table a k of f1, f2, for example... Of k primary key, two users in a very close to the time to update the table a
What happened to
UpWhereKeyOnly after a user to change the content of the subject, before a person can cover one after operation
UpWhereChanged change the content of both can be used, as long as they are in the same fields don't change
UpWhereAll before a user to change the content of the subject, after a change will fail, produce 'record not found abnormal

. This kind of situation is exist in all of the database design, including the c/s mode of the database, because, when you see the data, it is not in real time.

CodePudding user response:

refer to the second floor Comanche response:
this is a problem of hundred years ago, now will also be asked in

Cds.Com mandText:=' ';
The corresponding is
CDS. The Execute;
At this moment what it is not necessary to perform the open and close operation, as long as you have datasetprovider can perform, of course, there are options in datasetprovider (poAllowCommandText) command to be executed to allow t...

Top of the
  • Related