HomeActive Query BuilderAlternate names with MS SQL Server database

Alternate names with MS SQL Server database


Hi,
I have a very big database with huge amount of tables and views.
I would like to know something about the alternate names.
In the Active Query Builder the .Net Component has the UseAltNames property. I would be good if the alternate column names should be appeared in the query builder GUI instead of the short column names.
I use MS Sql Server 2008 but I cannot find any information that where should I store the alternate name in the server.

I would be happy if you can tell me instructions how to use and how to set the Alternate names with the MS Sql Server databases.

Thanks, Peter
Peter T
January 19 2010, 10:29 AM
Dear Peter,

The alternate names should be stored not within a database, but in the component's metadata container (QueryBuilder.MetadataContainer collection). The content of this collection can be saved and restored using XML file. There you may input and store your Alternate names.

You may find the metadata editor tool at the download page or you may call the QueryBuilder.MetadataContainer.Edit method from your applcation.

Code examples of working with metadata XML files can be found at http://www.activedbsoft.com/helpdesk/index.php?pg=forums.posts&id=6&pc=2 Loading metadata from XML file can also speed up the metadata loading process.

You may also input alternate names in the SQL Server database as descriptions. Descriptions will be loaded into the metadata container into the LongDescription attribute of each database object and field, but you'll have to re-assign it's value to the AltName attribute; this process can take long time in case of large database.
Sergey Smagin | email
15 hours, 52 mins since original post
Thank you for the answer but I still have some questions.

The only way for me is to store the altName in the description in the database.
I succeeded to set the altName to the LongDescription in the FormLoad event when all fields were loaded. Everything works correctly but the loading is a little bit slow.

The schema of the code was something like this:

private void Form_Load(object sender, EventArgs e)
{
mssqlMetadataProvider.Connection = new SqlConnection(connString);
queryBuilder.RefreshMetadata();
queryBuilder.MetadataContainer.LoadFields();

foreach <all MetaDataTable in the queryBuilder.MetadataContainer.Items>
{
foreach <all Fields in tha actual MetaDataTable>
{
actualField.AltName = actualfield.LongDescription;
}
}
}

1, Is the FormLoad the proper event when the fields of the tables are loaded and I can set the AltName to the Description?

2, The queryBuilder.MetadataContainer.Items property has hundreds of items, so the queryBuilder.MetadataContainer.LoadFields() command takes a long time to run.
(The double foreach cycle with the AltName setting runs very fast so that was not problematic.)
I would like to load the fields only for the user-created tables and user-created views and not for other system views and objects. Is there any option to do this?
Peter T
1 day, 2 hours since original post
Dear Peter,

There is a QueryBuilder.MetadataContainer.ObjectMetadataLoaded(MetadataContainer sender, MetadataObject metadataObject) event where you can assign AlternateNames for a single object. This way you won't have to call the MetadataContainer.LoadFields method.

Also you may find example of caching metadata information on client PC in the full-featured demo project.
Sergey Smagin | email
1 day, 13 hours since original post
This topic is closed