Trying to execute an update query where rows are variables from TEdit

May 02, 2021, at 5:50 PM

I have a table which has values that need to be updated. There are quite a few typos as different people have added items in the past, so I have to use 'like' despite everything.

I created a Form with all the necessary fields that need updating. I used simple TEdit and a TLabel. The plan is that one picks a type of item from an edit box and also use a TListBox.

Then one adds the information to be updated into each TEdit.

I create an update procedure as follows:

MyQuery1.SQL.Text := ' UPDATE TheTable SET iName = edtName.text WHERE iType like "%edtType.text%" ';
MyQuery1.SQL.Text := ' UPDATE TheTable SET iPart = edtPart.text WHERE iType like "%edtType.text%" ';

My problem is passing the edtVariables in the correct format. How does one add the "% before and %" after the edtVariable?

I tried '"%'+edtPart.text+'%"' and such like, but I've never had to do this at runtime before.

Answer 1

Using FireDAC in a parametrized query, you use ':' in front of a parameter name:

MyQuery1.SQL.Text := 'UPDATE TheTable SET iName = :NameText WHERE iType like :TheValue';

Then you set the parameter value before executing the request:

MyQuery1.ParamByName('TheValue').AsString := EdtType.Text;
MyQuery1.ParamByName('NameText').AsString := EdtName.Text;
Can I have only one Xamarin Content Page with no full screen in Android?

Can I have only one Xamarin Content Page with no full screen in Android?

I have seted android:windowFullscreen = false for achiving to fix an issue that was kicking out from screen some element views when soft keyboard is openI was able to solve the problem, but now my whole app has no full screen mode

Compser require maatwebsite/excel [closed]

Compser require maatwebsite/excel [closed]

Want to improve this question? Add details and clarify the problem by editing this post

Laravel 8 Quiz System [closed]

Laravel 8 Quiz System [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post

FormEmailer dropping CSS Inline to Gmail

FormEmailer dropping CSS Inline to Gmail

I have set up a FormEmailer script to run on a form/sheet I'm working onThe current aim is to have an email sent to a specific person after form submission with the questions and answers in a table (two columns, six rows)