A syntax error, but it can be compiled ///

Source: Internet
Author: User
A syntax error occurs. However, you can compile /// Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061221151440186.html
Hello, I have encountered the following problems when I first learned Delphi:
After connecting to an sqlserver database store with adoconnection, adoquery, datasource, and DBGrid
Use a button to trigger a query operation, Code As follows:
Storeall is the table in the database store.
The items in combox1 is the productname productnum field in the storeall table.
Items in combox2 is>, =,


Procedure tform3.button1click (Sender: tobject );
VaR
Stris: string;
Begin
If (combobox1.text = '') and (combobox2.text ='') and (edit1.text = '')
Then showmessage ('select query condition ')
Else
Begin
Stris: = 'select * From storeall where '+ trim (combobox1.text) +
Trim (combobox2.text) + ''' + trim (edit1.text) + '''';
If combobox1.text = 'productnum' then
Stris: = 'select * From storeall where '+ trim (combobox1.text) +
Trim (combobox2.text) + trim (edit1.text );
With adoquery1 do
Begin
Close;
SQL. Clear;
SQL. Add (stris );
Open;
End;
End;

End;

These codes can be compiled but the first line appears: ''syntax error during running.

Many sides of the review cannot find errors. Please advise ..

Procedure tform3.button1click (Sender: tobject );
VaR
Stris: string;
Begin
If (combobox1.text = '') or (combobox2.text ='') or (edit1.text = '')
Begin
Showmessage ('select query condition ')
Exit;
End;

Stris: = 'select * From storeall where '+ trim (combobox1.text)
+ Trim (combobox2.text) + quotedstr (TRIM (edit1.text ));
If combobox1.text = 'productnum' then
Stris: = 'select * From storeall where '+ trim (combobox1.text)
+ Trim (combobox2.text) + trim (edit1.text );
With adoquery1 do
Begin
Close;
SQL. Clear;
SQL. Add (stris );
Open;
End;
End;
End;

If (combobox1.text = '') or (combobox2.text ='') or (edit1.text = '') Then // I'm sorry if one then is missing
Begin
Showmessage ('select query condition ')
Exit;
End;


Stris: = 'select * From storeall where '+ trim (combobox1.text) +
Trim (combobox2.text) + ''' + trim (edit1.text) + '''';
Are these 'text' strings missing? Such as where '+ trim (combobox1.text) +' = '+ ...... and (or )......

This is a problem with SQL statements. We recommend that you use F8 to view the stris value or display stris to see if the SQL syntax is correct! In solution!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.