DatabaseName (Property)

Applies To:

DMCatalogItem object

Description:

Returns the name of the database associated with a table in the Table catalog. To retrieve this property correctly, you must connect to the database successfully, expand the Query Catalog tree manually (in Designer or the web client) or use the Catalog.Refresh() method, and use this property.

Action:

Read-only

Example 1:

This example shows how to expand the Table Catalog, count the number of catalog items, and write name of the database associated with a table to the Console window. The example assumes that there is a connection to the database, and the Table Catalog has been refreshed and expanded.

var  TableCatalog = ActiveDocument.Sections["SalesQuery"].DataModel.Catalog
var TableCount = ActiveDocument.TableCatalog.CatalogItems.Count
for (j=1;j<=TableCount;j++)
Console.Writeln (TableCatalog.CatalogItems[j].Name)

Example 2:

This example shows how to return the connection status of the database, connect to the database, refresh the Table Catalog, expand the Table Catalog, count the number of catalog items, and write the database name associated with a table to Console window. When using this property, the database connection must have the Prompt for Database Name enabled; otherwise, database names are not tricked in the Table Catalog.

if (!ActiveDocument.Sections["Query"].DataModel.Connection.Connected)
ActiveDocument.Sections["Query"].DataModel.Connection.Connect(true)
var  TableCatalog = ActiveDocument.Section["Query"].DataModel.CatalogTableCatalog.Refresh();
var TableCount = TableCatalog.CatalogItems.Count for (j=1;j<=TableCount; j++)
Console.Writeln (TableCatalog.CatalogItems[j].DatabaseName+"."+TableCatalog.CatalogItems[j].Owner+"."+ TableCatalog.CatalogItems[j].Name)