I have done some searching and can't find a definitive answer to this one.
I am just getting into SQL so be gentle. Using D5, TNTUnicode, Zeos and SQLite3
I have a DBGrid with all the Account names in the tblAccounts showing. I have a DBGrid with all the Folders in the tblFolders showing.
In the OnCellClick of the Accounts grid I have an SQL query
qryFolders.Close;
qryFolders.SQL.Clear; // Not really needed as I am assigning the Text next - but :)
qryFolders.SQL.Text:=
'SELECT Folder FROM tblFolders WHERE UPPER(Account)="FIRSTTRADER"'
qryFolders.ExecSQL;
tblFolders.Refresh;
In my application, nothing happens, I still have the full list of Folders visible.
In the SQL-Expert desktop that line works fine and displays only the two Folders associated with that Account. In that app it keeps displaying the full list of Folders
If I step through the OnCellClick it shows the correct Text etc.
Where am I going wrong?
Thanks
ExecSQLis a method to executeinsert/updateor other SQL statements that return no cursors.ExecSQLover aselectstatement is useless, since you usually want to get the returning cursor.ExecSQL, as @jachguate says, is for DML/DDL statements or SQL statements that return no results (likeINSERTorUPDATE). To retrieve a cursor (rows of data) from aSELECT, just useqryFolders.Open;instead.