Search code examples
sql-serverdelphi-7delphi-xe2tadoquery

HOW TO Using ADOQuery sum in Delphi


I have this SQL query:

image

As you can see, it works fine. Except when I use it in Delphi.

I use TDBLookupComboBox, TEdit, and TButton. My idea is, whenever I click on the TButton, the EXE goes to check the table in SQL using information in the DBLookupComboBox and puts the result in the TEdit.

This is my Delphi code:

image


Solution

  • In your Delphi code, you are using double quotes: "

    Your string needs to be enclosed in single quotes: '

    To embed a single quote in your Delphi string, need to use two single quotes: ''

    S := 'hey"there';        // hey"there
    
    S := 'hey''there';       // hey'there
    
    S := 'specification='''; // specification='
    
    S := '''';               // '