Place the QueryBuilder component on the form:
using ActiveDatabaseSoftware.ActiveQueryBuilder;
...
QueryBuilder queryBuilder1 = new QueryBuilder();
Place required metadata and syntax provider components on the form. Define a proper database connection object for the metadata provider:
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString = "<your connection string here>";
OLEDBMetadataProvider metadataProvider = new OLEDBMetadataProvider();
metadataProvider.Connection = connection;
GenericSyntaxProvider syntaxProvider = new GenericSyntaxProvider();
Link the components above to the QueryBuilder by setting MetadataProvider and SyntaxProvider properties:
queryBuilder1.MetadataProvider = metadataProvider;
queryBuilder1.SyntaxProvider = syntaxProvider;
Place the PlainTextSQLBuilder component on the form to get SQL code generated by the QueryBuilder component with formatting. Link it to the QueryBuilder object:
PlainTextSQLBuilder sqlBuilder = new PlainTextSQLBuilder();
sqlBuilder.QueryBuilder = queryBuilder1;
Add the TextBox or any other text editing component to a form.
Now you should establish connection between SQLBuilder and the TextBox components.
Enter the following code to Leave event of TextBox component:
if (textBox1.Modified)
{
try
{
queryBuilder1.SQL = textBox1.Text;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Parsing error");
}
textBox1.Modified = false;
}
Enter the following code to SQLUpdated event of SQLBuilder component:
textBox1.Text = sqlBuilder.SQL;
queryBuilder1.InitializeDatabaseSchemaTree();
That's all! Now you can run your application.