D
D
Durilka962021-05-01 22:52:59
SQL
Durilka96, 2021-05-01 22:52:59

How to correctly implement search in DBGrid through LabelEdit1 in C++ Builder?

There are 2 tables, the column structure is attached in the screenshots 608db0213b29f572289612.png
608db0435a177436466283.png
. I'm trying to implement a search through LabelEdit1 on the KeyPress event as follows:

if (N12->Checked==true) {
  ADOQuery1->Close();
  ADOQuery1->SQL->Clear();
  ADOQuery1->SQL->Add ("SELECT  a.familia,  c.kolichestvo, c.ch, c.mes, c.god FROM sotrudnik a,  main c WHERE a.familia LIKE '%" + LabledEdit1->Text +  "%' ORDER BY a.familia;");
  ADOQuery1->Open();
  gridM();     //класс для обновления столбцов в dbgrid
}

the problem of data search is that id_s are stored in the main table, which correspond to id_s from the sotrudnik table, and the search is performed by human letters in labeledit, because the data in the dbgrid is shown not by id_s but by surnames, where I am mistaken in the query, it displays incorrectly , and how to add int variables to sql query IntToStr() does not help, swears at him

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question