A
A
animr2015-05-24 22:05:20
SQL
animr, 2015-05-24 22:05:20

How to compose an SQL query, correctly for declaring data in the *dbf database?

People help to make SQL - request correctly if I write thus the code:
dmContanierIcon.quAdmissionProduct.Active := False;
dmContanierIcon.quAdmissionProduct.Close;
dmContanierIcon.quAdmissionProduct.SQL.Clear;
dmContanierIcon.quAdmissionProduct.SQL.Text := 'UPDATE dbt_AdmissionProduct SET p_id = '+IntToStr(varFirstRecId)+' WHERE p_product = "'+varArticleUpdateId+'"';
dmContanierIcon.quAdmissionProduct.ExecSQL;
//dmContanierIcon.quAdmissionProduct.Open;
dbgrdAdmissionProduct.DataSource.DataSet.Next;
I get the following error:
993ad0244b8c4ba1bead6101238c8628.png
what if I uncomment
dmContanierIcon.quAdmissionProduct.Open;
trail comes out. mistake:
6726a8f79c584d34a82ba758af22884e.png
please tell me how to do it right ... Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2015-05-24
@animr

Use instead of Open, ExecSQL and all

I
iloer, 2015-05-25
@iloer

well firstly
dmContanierIcon.quAdmissionProduct.SQL.Text := 'UPDATE dbt_AdmissionProduct SET p_id = '+IntToStr(varFirstRecId)+' WHERE p_product = "'+varArticleUpdateId+'"';
it would be more correct to write it as:

dmContanierIcon.quAdmissionProduct.SQL.Text := UPDATE dbt_AdmissionProduct SET p_id = :varFirstRecId WHERE p_product = :varArticleUpdateId;
dmContanierIcon.quAdmissionProduct.ParamByName('varFirstRecId').AsInteger := varFirstRecId;
dmContanierIcon.quAdmissionProduct.ParamByName('varArticleUpdateId').AsString := varArticleUpdateId;
dmContanierIcon.quAdmissionProduct.ExecSQL;

and about the error, then why do you need to do Next after Update? ExecSQL method does not return Dataset. Delphi also informs you about it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question