Question about delphi 7 query

2

I'm having a problem trying to run an update query in my database, delphi gives an error as an incorrect syntax, but I could not find the problem. Could someone help me please?

Follow prints:

    
asked by anonymous 23.05.2016 / 20:38

2 answers

5

Try:

'UPDATE Tbl_aluno SET nome = '+QuotedStr(edit_nome.text)+'
WHERE PRONTUARIO ='+QuotedStr(.....)

QuotedStr ensures that the parameter is enclosed in quotation marks, for example: name = 'AUGUSTO'

    
24.05.2016 / 14:22
2

The error occurred because your query has no quotation marks in the text fields.

There are a few ways to put quotation marks around a delphi string:

  • QuotedStr ('string') function:

    ShowMessage(QuotedStr('teste'));
    
  • Use three single quotes:

    ShowMessage('''teste''');
    
  • Concatenate with ASII39 code

    ShowMessage(#39+'teste'+#39);
    

    or

    ShowMessage(Chr(39)+'teste'+Chr(39));
    
  • 30.05.2017 / 22:32