Active Query Builder support area

Unable to render Tree view of database schema

Avatar
  • updated
  • Answered

Hi Team, 

i was able to render the tables from the given SQL along with the mappings. But unable to render the tree nodes on the left hand side.

I did with queryBuilder.MetadataStructure.Refresh(); this did not help ...

I am using the below code snippet.

protected void Page_Load(object sender, EventArgs e)
{
// Get an instance of the QueryBuilder object
var qb = QueryBuilderStore.GetOrCreate("Simple", InitializeQueryBuilder);

QueryBuilderControl1.QueryBuilder = qb;
ObjectTreeView1.QueryBuilder = qb;
Canvas1.QueryBuilder = qb;
Grid1.QueryBuilder = qb;
SubQueryNavigationBar1.QueryBuilder = qb;
SqlEditor1.QueryBuilder = qb;
StatusBar1.QueryBuilder = qb;
}

//sets the properties of the Querybuilder
private void InitializeQueryBuilder(QueryBuilder queryBuilder)
{

// Turn this property on to suppress parsing error messages when user types a non-SELECT statement.
queryBuilder.BehaviorOptions.AllowSleepMode = false;

// Assign an instance of the syntax provider which defines SQL syntax and metadata retrieval rules.
queryBuilder.SyntaxProvider = new MSSQLSyntaxProvider();
queryBuilder.MetadataStructure.Refresh();
}

public bool connectionStatus(string connStr)
{
var qb = QueryBuilderStore.Get("Simple");
bool result = false;
InitializeQueryBuilder(qb);


qb.MetadataProvider = new OLEDBMetadataProvider
{
// Assign an instance of DBConnection object to the Connection property.
// In this demo: create a new instance of OLEDBConnection for the "Northwind.mdb" MS Access database.
Connection = new OleDbConnection(connStr)

};

try
{
qb.MetadataProvider.Connect();
result = qb.MetadataProvider.Connected;
qb.MetadataStructure.Refresh();

}
catch (Exception e)
{
result = false;
}

return result;

}

can you please help me where is the problem ?

How would you rate the customer service you received?

Satisfaction mark by bharathkumar kristam 3 months ago

Thanks for the support

Add a comment about quality of support you received (optional):

Avatar
Andrey Zavyalov, PM
  • Answered

Your code doesn't seem correct. The metadataProvider initialization routine should be added to the InitializeQueryBuilder procedure, right before the queryBuilder.MetadataStructure.Refresh call.

I don't think this is wise to establish a new DB connection for each client and this may lead to many issues with high load. This is reasonable only if the number of concurrent db connections is strictly limited and your DB server can handle it.

In other cases, I recommend you to save metadata to a cache. Read about this here: 

- Saving metadata to XML file 

Configuration file for Active Query Builder ASP.NET Edition 3.0