Doubt about query in Delphi 7

Asked

Viewed 873 times

2

I have a certain problem when trying to run an update query in my database, Delphi gives error as incorrect syntax, but I could not find the problem. Could someone please help me ?

Follows prints:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • 2

    Use parameters (Parameters) or treat the quotes in the SQL mount , search by quotedstr

2 answers

5


Try:

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

Quotedstr ensures that the parameter is enclosed in quotes, for example: name='AUGUSTO'

2

Error occurred because your query has no quotes in the text fields.

There are a few ways to quote a string in Delphi:

  1. Function Quotedstr('string'):

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

    ShowMessage('''teste''');
    
  3. Concatenate with code ASI39

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

    or

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.