Three, how to use ClientdataSet.CommandText, update, insert data. . .

Category: C/C++ -> Database Author: qppqqpq Date: 2011-07-23 19:49:49
 
qppqqpq
2011-07-23 19:49:49
The middle layer is ADOquery, DataSetProvider
the Client to write SQL statements to query data correctly. . .
But how can update, insert data yet. .
update always reported SQL server is empty, do not have a
ClientdataSet corresponds to a ADOquery, DataSetProvider, and the SQL statement written in the middle tier you?
wxd_jb203
2011-07-23 19:55:39
If you use three, it is best not to write the client SQL, and written in the middle layer.

can be inserted into the record:
with ClientDataSet1 do
begin
Open;
; Append;
FieldValues ​​['fieldname']: = fieldvalue;
Post;
ApplyUpdates (0) ;/ / sentence can be written In another sentenced to realize the batch update
end;

If you use SQL to insert records, there is no problem, but the server must allow clients to modify SQL:
with ClientDataSet1 do
begin
Close;
CommandText: = 'INSERT INTO tablename (fieldname) VALUES (fieldvalue ');
Execute;
end;
zskingko
2011-07-23 20:15:38

with ClientDataSet1 do
begin
Open;

you extract data, ADOQuery sql statement to write out where?

you are not common a few ClientDataSet connected?

paullgk
2011-07-23 20:29:26
sql and commandtext right on it updated. .
otherwise only query
dragon5215
2011-07-23 20:43:06
put DataSetProvider the Options set AllowCommandText = True
lr8746
2011-07-23 20:54:57
Everyone says three words are not in the client write SQL, then pass from the client SQL and application server returns a dataset using SQL What is the difference, where the benefits!
liu2825995
2011-07-23 21:05:40
Upstairs brothers (hiflower (flower)) said that very clearly.
donghaozhang
2011-07-23 21:22:18
see your update statement
mp4player
2011-07-23 21:51:20
operate on a single table, you can write in ADOQuery.SQL.Text query this table ... and then like you can
If no query. should be updated accordingly handwriting on multiple tables, manipulate ...
this method does not work ..
fx133189966
2011-07-23 22:13:08
If the client does not write SQL, it is the middle layer of the corresponding Query must write SQL. (SELECT statement)
or write on the client side SQL, but not recommended.
duolaameng17
2011-07-23 22:44:03
why moan and groan?
problems still can not solve? .... depressed ...
hj77585212
2011-07-23 23:18:42
heroes have to say very clearly, in accordance with the method should be no problem the
does not advocate the client submit SQL statements, the main purpose is to try to access the database service business encapsulated in the middle layer, the client only receives and submit the entire data set.
emodedidi
2011-07-23 23:44:28
It seems that you are doing things in this area less! !
jkking153
2011-07-24 00:18:37
far more than is recommended, and if you watched JAVA and. NET three-layer structure, which is simply not possible.
yanleichina
2011-07-24 00:57:54
client directly sql, do so only as a middle layer to pass sql role, the multilayer structure still do
wuweisj
2011-07-24 01:15:53
I have it set to AllowCommandText DataSetProvider of Options = True,
update SQL server always reported as empty
hgl80
2011-07-24 01:49:18
middleware, ADOQuery not write any query or table, and do not want to update the same query. . . And put DataSetProvider the Options set AllowCommandText = True;
/ / /
Client:

with ClientDataSet1 do
begin
Open;
Append;
FieldValues ​​['fieldname']: = fieldvalue;
. . . .
Post;
ApplyUpdates (-1);
end;

submitted unsuccessful. . . . . . . However, in the two layers is no problem. . .