ferhad
asked on
Changing values of boolean field of dataset with SQL
With the following code I am trying to change all records of Show field into False that matchs with to the following condition.
clientID :=5; contractNo := 10;
QuerySort.Active := False;
QuerySort.SQL.Text := 'UPDATE DEBTS SET Show=' + '''' + '''False''' + ''''
+ ' WHERE (ClientID= IntToStr(clientID))and(Con tractNo=co ntractNo)' ;
QuerySort.ExecSQL;
clientID and contractNo are the variables into which I am giving values above.
clientID :=5; contractNo := 10;
QuerySort.Active := False;
QuerySort.SQL.Text := 'UPDATE DEBTS SET Show=' + '''' + '''False''' + ''''
+ ' WHERE (ClientID= IntToStr(clientID))and(Con
QuerySort.ExecSQL;
clientID and contractNo are the variables into which I am giving values above.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both codes kretzschmar yours and esoftbg yours woks but they are giving the same error. ("No current record")
ASKER
What should I do in order to prevent this error ?
do you try to open the query?
if so, then you must replace the statement with your
previous select-statement before opening
meikl ;-)
if so, then you must replace the statement with your
previous select-statement before opening
meikl ;-)
ASKER
No I am just executing it
const SQL = 'UPDATE DEBTS SET Show=False WHERE (ClientID= :ClientID) and (ContractNo=:contractNo)';
querysort.Active := False;
querysort.sql.text := SQL;
querysort.parambyname('Cli entID').As Integer := ClientID;
querysort.parambyname('con tractNo'). AsInteger := contractNo;
querysort.ExecSQL;
That's all what I am doing.
const SQL = 'UPDATE DEBTS SET Show=False WHERE (ClientID= :ClientID) and (ContractNo=:contractNo)';
querysort.Active := False;
querysort.sql.text := SQL;
querysort.parambyname('Cli
querysort.parambyname('con
querysort.ExecSQL;
That's all what I am doing.
I am working with your Tables that you sent me by e-mail. It works fine here....
If you want I will send you above code by e-mail.
emil
If you want I will send you above code by e-mail.
emil
Long long ago when Delphi 2 was a yanger 'No current record' make mad many programmers who update records with a values that sends visual controls current record out of filter applayed by query or other datasets. So reopening of query AFTER update produces 'No current record'.
Is I'm right?
Is I'm right?
good point, mikprog
ASKER
Please, send it me esoftbg
MikProg but I am not reopenning my query component after update procedure.
MikProg but I am not reopenning my query component after update procedure.
MikProg means,
there may dataaware-controls attached via a TDatasource to the query,
which causes this problem
-> deAttach the Dataset from the Datasource before
-> DataSource1.Dataset := nil;
there may dataaware-controls attached via a TDatasource to the query,
which causes this problem
-> deAttach the Dataset from the Datasource before
-> DataSource1.Dataset := nil;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have found that two components simultaniously using the same dataset(TTable and TQuery). Before calling update method I closed Table. After execution of update I am calling Open method of table again. Now everything works. :)
just to ask about:
why a c-grade??
why a c-grade??
ASKER