I thought to remember Delphi (he did not touch him for 8 years).
I make a query string:

Form1.ADOQuery1.SQL.Add('INSERT INTO exam_users (`family`, `name`, `patronymic`, `birthdate`, `passport_serial`, `passport_number`,' +'`passport_date`, `organization`, `organization_code`, `programma`, `level`, `civilian_weapons`, `group`, `num_certificate`,' +'`date_certificate`, `date_exam`, `job`, `telephone`, `user_files`, `time_rec`, `date_rec`, `status`, `description`,)' +'VALUES ('+Edit1.text+', '+Edit2.text+', '+Edit3.text+', '+Edit4.text+', '+Edit5.text+', '+Edit6.text+', '+Edit7.text+', '+Edit8.text+',' +''+Edit9.text+', '+Edit10.text+', '+Edit11.text+', '+Edit12.text+', '+Edit13.text+', '+Edit14.text+', '+Edit15.text+', '+Edit16.text+', '+Edit3.text+',' +''+Edit17.text+', '+Edit18.text+', '+Edit19.text+', '+Edit20.text+', '+Edit21.text+', '+Edit22.text+', '+Edit23.text+''); 

Took from my working PHP code.
Then I read about the parameters, since it’s difficult to see quotes in Delphi and made this option:

 Form1.ADOQuery1.SQL.Add('INSERT INTO exam_users (`family`, `name`, `patronymic`, `birthdate`) VALUES (:family, :name, :patronymic, :birthdate'); Form1.ADOQuery1.Parameters.ParamByName('family').Value:= Edit1.text; Form1.ADOQuery1.Parameters.ParamByName('name').Value:= Edit2.text; Form1.ADOQuery1.Parameters.ParamByName('patronymic').Value:= Edit3.text; Form1.ADOQuery1.Parameters.ParamByName('birthdate').Value:= Edit4.text; 

And still the error (Exception) falls out:

enter image description here

  • That's right that Parameters.ParamByName passed - so much more readable and safe code. The limit on the number of characters here seems to be nothing to do with. - Kromster
  • four
    I don't know what you found in your SQL queries - both with gross syntax errors. In both, the bracket of the VALUES section is not closed, in the first one there is also a " description ,)" - there should not be a comma here. - Shallow
  • @ Let's not argue, otherwise I will give the code and you will argue. The code is in PHP. Debugged and working. You know that PHP uses the '$name', style '$name', And after discription, the comma remained from the abbreviation of the '$ip_address when migrating from PHP. (And this is really my omission). And I also see the bracket lost. PS I wrote - Delphi did not open for 8 years. And I am engaged in a whole training center, two portals, and not one programming. You know the crisis ... - I_CaR

2 answers 2

Bracket is not closed:

 Form1.ADOQuery1.SQL.Add('INSERT INTO exam_users (`family`, `name`, `patronymic`, `birthdate`) VALUES (:family, :name, :patronymic, :birthdate)'); 
  • Thank you for your attention. Looks confused with these quotes and transferring them to PHP. - I_CaR

And one more simple quotes solution.
As he wrote about 8 years, he did not program in Delphi, but the lessons remained. And I found a solution for quotes in the old code.
Just wrap the variables in " " :

 Form1.ADOQuery1.SQL.add('INSERT INTO exam_users (`family`, `name`, `patronymic`, `birthdate`)' +' VALUES ("'+Edit1.text+'", "'+Edit2.text+'", "'+Edit3.text+'", "'+Edit4.text+'")'); 
  • Through the parameters everything is solved much easier and without perversion. - androschuk