ComponentOne Query 8.0
Maintaining, Saving and Restoring Queries

It is often needed to allow the user to save queries in a repository so that they can be reused later. Such repository can be a database, a file directory, or an XML file storing multiple queries, or another kind of storage. C1Query does not limit developer’s choice to a specific storage or media. It provides general-purpose methods for saving/restoring a query. Using these methods, you can easily program a query repository or any other form of query maintenance facilities required in your application.

SaveToXMLFile and LoadFromXMLFile methods allow you to save/restore queries in a file.

SaveToXML and LoadFromXML methods allow you to save/restore a query as a String value. The saved query is structured in a standard XML form, but what matters is that the query is now represented by a single String. That string can be stored in a database or another storage, together with query description and other attributes, if you need them.

Restoring a query does not automatically update the control display. It is intentional, since in some cases it is needed to modify the query contents after restoring it to a control (see Accessing and Modifying Query Items about how to do it). When you are done with restoring/modifying the query, call the Render method to update display. If you forget to call Render, the control will remain in unstable state and unpredictable results can follow.

An example showing how to maintain a repository of queries in an XML file can be found in the SAMPLES directory. You can easily modify that sample to store queries in a database or another storage.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback