What is the logic error that is super difficult to solve? Urgent

Source: Internet
Author: User
What is the logic error that is super difficult to solve? Urgent: Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061222173752156.html

My Program DBGrid, adoquery, next record, last record, and delete current record are displayed on the panel. DBGrid is empty when the program starts, click any one of the buttons above, and the program reports an error and exits.
Take the "delete" button as an example. My program is as follows:
Procedure tform1.button5click (Sender: tobject );
Begin
Adoquery1.open;
If adoquery1.recordcount = 0 then
MessageBox (0, 'setcommmask error! ', 'Notice', mb_ OK)
Else
If application. MessageBox ('Do you want to delete the current record? ',' Hint ', mb_yesno) = id_yes then
Adoquery1.delete;
End;
To check whether adoquery1.recordcount = 0, adoquery1.open is required. However, when adoquery1.recordcount = 0, adoquery1. SQL. text: = ''at this time, you cannot connect to the database. Of course, you cannot calculate recordcount. After thinking about it for a day, your head is big. Which of the following can help me? I'm so excited.
If the problem is not clear, QQ: 110546987 online wait, bearzmc@163.com. Thank you.

Didn't understand what it was about?

Procedure tform1.button5click (Sender: tobject );
Begin
Adoquery1.close;
Adoquery1. SQL. Clear;
Adoquery1.add ('select * from table where .....');
Adoquery1.open;
If adoquery1.recordcount = 0 then
MessageBox (0, 'setcommmask error! ', 'Notice', mb_ OK)
Else
If application. MessageBox ('Do you want to delete the current record? ',' Hint ', mb_yesno) = id_yes then
Begin
Adoquery1.close;
Adoquery1. SQL. Clear;
Adoquery1. SQL. Add ('delete table where ....');
Adoquery1.execsql;
End;
End;

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.