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!