Loading the SQL property from string list object
Go Up to Specifying a SQL statement at runtime
You can also use the Assign method of the SQL property to copy the contents of a string list object into the SQL property. The Assign method automatically clears the current contents of the SQL property before copying the new statement. For example, copying a SQL statement from a TMemo component:
CustomerQuery.Close; CustomerQuery.SQL.Assign(Memo1.Lines); CustomerQuery.Open;
- Note: If the SQL statement is a parameterized query, set the initial values for the parameters and call
Preparebefore opening or executing the query. Explicitly callingPrepareis most useful if the same SQL statement is used repeatedly; otherwise it is called automatically by the query component.