How to handle ADO Query with results vs. Query with no results?
问题 I run various SQL statements using MSSQL and ADO. The code sequence looks like this: aADOQuery.Active := False; aADOQuery.SQL.Text := ' MY SQL STATEMENT '; aADOQuery.ExecSQL; aADOQuery.Active := True; The last statement fails if the SQL return result is empty. How to check for this case to avoid run time errors? Note: The SQL statement comes from a memo where the user is typing the SQL. 回答1: If your query returns a record set ( SELECT statements) you should not use ExecSQL but simply