Simak secara seksama Edit/Update and Delete Sintack for sql in lazarus

DELETE

sqlquery1.SQL.clear;
    SQLQuery1.SQL.add ('DELETE FROM clientes WHERE cli_id = :cli_id ');
    sqlquery1.Params.ParamByName('cli_id').Asstring:= edit6.text;

    if(MySQL50Connection1.connected=false)then MySQL50Connection1.connected:=true;
    if(SQLTransaction1.active=false)then SQLTransaction1.active:=true;

    SQLQuery1.ExecSQL;
    SQLQuery1.Close;
    SQLTransaction1.CommitRetaining;

UPDATE

sqlquery1.SQL.clear;
    SQLQuery1.SQL.add ('UPDATE clientes ');
    SQLQuery1.SQL.add ('SET clientes.cli_nome= :cli_nome, clientes.cli_nasc= :cli_nasc, clientes.cli_morada= :cli_morada, clientes.cli_telf= :cli_telf, clientes.cli_telem= :cli_telem, ');
    SQLQuery1.SQL.add ('clientes.cli_bi= :cli_bi, clientes.cli_regime= :cli_regime, clientes.cli_benefic= :cli_benefic, clientes.cli_prof= :cli_prof, clientes.cli_email= :cli_email, clientes.cli_notas= :cli_notas ');
    SQLQuery1.SQL.add ('WHERE clientes.cli_id= :cli_id ;');

    sqlquery1.Params.ParamByName('cli_nome').Asstring:=UTF8DECODE(edit7.text);
    sqlquery1.Params.ParamByName('cli_nasc').Asstring:=edit8.text;
    sqlquery1.Params.ParamByName('cli_morada').Asstring:=UTF8DECODE(memo2.text);
    sqlquery1.Params.ParamByName('cli_telf').Asstring:=edit9.text;
    sqlquery1.Params.ParamByName('cli_telem').Asstring:=edit10.text;
    sqlquery1.Params.ParamByName('cli_bi').Asstring:=edit11.text;
    sqlquery1.Params.ParamByName('cli_regime').Asstring:=edit12.text;
    sqlquery1.Params.ParamByName('cli_benefic').Asstring:=edit13.text;
    sqlquery1.Params.ParamByName('cli_prof').Asstring:=UTF8DECODE(edit14.text);
    sqlquery1.Params.ParamByName('cli_email').Asstring:=edit15.text;
    sqlquery1.Params.ParamByName('cli_notas').Asstring:=UTF8DECODE(memo3.text);
    sqlquery1.Params.ParamByName('cli_id').Asstring:=edit6.text;

    if(MySQL50Connection1.connected=false)then MySQL50Connection1.connected:=true;
    if(SQLTransaction1.active=false)then SQLTransaction1.active:=true;

    SQLQuery1.ExecSQL;
    SQLQuery1.Close;
    SQLTransaction1.CommitRetaining;   
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s