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;