An error occurred while writing the query statement. An error occurred while displaying the data not found.

Source: Internet
Author: User
An error occurred while writing the query statement. An error occurred while displaying the data that could not be found. For more information, see Delphi/Windows SDK/API.
Http://www.delphi2007.net/DelphiBase/html/delphi_20061205203545276.html
If (form4.rbdepno. Checked) then
Begin
If trim (edit1.text) = ''then
Begin
Messagedlg ('the Department number cannot be blank! ', Mtwarning, [mbok], 0 );
Exit;
End
Else
Begin
S: = 'select * From depart where departid = '+ edit1.text;
If (S = '') then
Begin
Application. MessageBox ('the specified field in the database table has no records found! ', 'Records not found', mb_ OK );
End
Else
Query1. SQL. Add (s );
Query1.open;
End;


If (S = '') then
Begin
Application. MessageBox ('the specified field in the database table has no records found! ', 'Records not found', mb_ OK );
About this section Code If no matching field is found, the system prompts "no records are found for the specified field in the database table! ", Always running error. Can you see where the problem should be changed?

If (S = '') then
Begin
Application. MessageBox ('the specified field in the database table has no records found! ', 'Records not found', mb_ OK );
End
// The above judgment is superfluous, because s is definitely not ''---- You have assigned a value before!


It should be written after query1.open:
If query1.recordcount <1 then no records found!

Also, before query1. SQL. Add (), you should write at least:
Query1.close;
Query1. SQL. Clear;

The problem has been solved. Thank you ~

OK, you are so lucky! Congratulations! Close the post!

I didn't expect you to close the post so quickly! This is a good style! I like it!

Query1.close;
Query1. SQL. Clear; I wrote this before the query operation ~ Thank you ~
I don't know a lot about the new users, so I am asking you to help me more.

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.