There are two ways of specifying the text to be displayed for a particular database field - with a text global resource or with database extended properties. The two mechanisms are explained below.
Here is an example of the steps that smartDBforms.NET takes in order to determine the Caption for the database column ProductName in table Products.
The global resource .resx files are located in the special ASP.NET folder App_GlobalResources. The resourceClassKey setting in Web.config specifies the name of a global resource file. For localization multiple .resx files are created. They have the same name with different suffix, which determines the language of the resource. For more information see MSDN - ASP.NET Web Page Resources Overview.
In the .resx
file you put string resources which are displayed in the user-interface elements
such as labels.
The name of the String resource uniquely identifies a database column, a foreign
key or a database table. Its suffix determines the purpose of the text. For example
a String resource with name Products.ProductName.Caption
specifies the text of the label for the
ProductName data column of the Products data table.
Using global resource is not mandatory. If no global resource is specified then
smartDBforms.NET constructs default texts for caption and description. Another alternative
for specifying texts is to use the database extended properties.
You can even mix this two mechanisms. In this case the global resource
mechanism has priority over the database extended properties.
Here is the list of the different kinds of String resource IDs:
For Microsoft Sql Server the tables can belong to a specific schema. The schema names are case sensitive. The default
schema is dbo. If the table
does not belong to the default schema then the schema name should also be included in the
resource IDs. For example if the a table belongs to a custom
schema the IDs patterns will be:
{BaseSchemaName}.{BaseTableName}.{BaseColumnName}.Caption
{BaseSchemaName}.{FKRelationName}.Caption
In case the database table uses a specific schema, make sure to specify the schema
in the SELECT statement. For example: SELECT * FROM Production.Product.
For more information see
SQL Server 2005 documentation.
| Name pattern | Description |
|---|---|
{BaseTableName}.{BaseColumnName}.Caption
|
Specifies the caption of the database column. For more information see API - FieldSchema.Caption Property. |
{BaseTableName}.{BaseColumnName}.Description
|
Specifies the description of the database column. For more information see API - FieldSchema.Description Property. |
{FKRelationName}.Caption
|
Specifies the caption when the database column participates in a foreign key relation. For more information see API - FieldSchema.FKCaption Property. |
{FKRelationName}.Description
|
Specifies the description when the database column participates in a foreign key relation. For more information see API - FieldSchema.FKDescription Property. |
{FKRelationName}.NULLValueCaption |
Specifies the text that is displayed when the database column participates in a foreign key relation and its value is NULL. For more information see API - FieldSchema.FKNULLValueCaption Property. |
{FKRelationName}.NULLValueDescription |
Specifies the text description when the database column participates in a foreign key relation and its value is NULL. For more information see API - FieldSchema.FKNULLValueDescription Property. |
{BaseTableName}.RowCaptionExpression |
Specifies the sql expression that is used to calculate the text that represents
the foreign key parent row in a user-interface control( For example: a drop-down
list ). For more information about the sql syntax see MSDN - DataColumn.Expression Property |
{BaseTableName}.RowDescriptionExpression |
Specifies the sql expression that is used to calculate the text description that represents
the foreign key parent row in a user-interface control( For example: a drop-down
list ). For more information about the sql syntax see MSDN - DataColumn.Expression Property |
{BaseTableName}.ORDERBY |
Specifies the sql expression to be used in the ORDER BY clause when selecting
the table from the database. The ORDER BY is executed by the DB server.
This is used only when selecting the table as foreign key table. You can specify
multiple columns delimited by comma. For example: "LastName, FirstName" Please note:
It is important to make sure the columns used are sortable and exist. In case of inappropriate columns or wrong syntax the table and foreign keys to it will not be created. |
Anonymous.{ColumnName}.Caption |
Specifies the caption for a data column which is created on the fly in the SQL select statement. Such columns do not have a parent database table. |
Anonymous.{ColumnName}.Description |
Specifies the description for a data column which is created on the fly in the SQL select statement. Such columns do not have a parent database table. |
Database extended properties can be used to specify the caption and description texts for the database columns, tables and foreign keys. This mechanism can be used instead or together with a global resource file.
The extended properties for a MS SQL Server database can be modified with Microsoft SQL Server Management Studio Express or Query Analyzer.
All the extended properties for a database column are available at runtime in the FieldSchema.ExtendedProperties property.
Here are the names of the smartDBforms.NET extended properties.
| Extended property | Description |
|---|---|
| SDBF_Caption | The caption of the database column. For more information see API - FieldSchema.Caption Property. |
| SDBF_CaptionResID | Used to override the default resource id for the column caption. The resource id is used to extract the value from the global resource. |
| SDBF_Description | The description of the database column. For more information see API - FieldSchema.Description Property. |
| SDBF_DescriptionResID | Used to override the default resource id for the column description. The resource id is used to extract the value from the global resource. |
| Extended property | Description |
|---|---|
| SDBF_Caption | The caption of the foreign key. For more information see API - FieldSchema.FKCaption Property. |
| SDBF_CaptionResID | Used to override the default resource id for the caption. The resource id is used to extract the value from the global resource. |
| SDBF_Description | The description of the foreign key. For more information see API - FieldSchema.FKDescription Property. |
| SDBF_DescriptionResID | Used to override the default resource id for the description. The resource id is used to extract the value from the global resource. |
| SDBF_NULLValueCaption | The text to display when the value of the data base column that participates in the foreign key is NULL. For more information see API - FieldSchema.FKNULLValueCaption Property. |
| SDBF_NULLValueCaptionResID | Used to override the default resource id for the null value caption. The resource id is used to extract the value from the global resource. |
| SDBF_NULLValueDescription | The description to display when the value of the data base column that participates in the foreign key is NULL. For more information see API - FieldSchema.FKNULLValueDescription Property. |
| SDBF_NULLValueDescriptionResID | Used to override the default resource id for the null value description. The resource id is used to extract the value from the global resource. |
| Extended property | Description |
|---|---|
| SDBF_RowCaptionExpression |
Specifies the sql expression that is used to calculate the text that represents
the foreign key parent row in a user-interface control( For example: a drop-down
list ). For more information about the sql syntax see MSDN - DataColumn.Expression Property |
| SDBF_RowCaptionExpressionResID | Used to override the default resource id for row caption expression. The resource id is used to extract the value from the global resource. |
| SDBF_RowDescriptionExpression |
Specifies the sql expression used to calculate the text description that
represents the foreign key parent row in a user-interface control( For example:
a drop-down list ). For more information about the sql syntax see MSDN - DataColumn.Expression Property |
| SDBF_RowDescriptionExpressionResID | Used to override the default resource id for the row description expression. The resource id is used to extract the value from the global resource. |
|
Specifies the sql expression to be used in the ORDER BY clause when selecting
the table from the database. The ORDER BY is executed by the DB server.
This is used only when selecting the table as foreign key table. You can specify
multiple columns delimited by comma. For example: "LastName, FirstName" Please note:
It is important to make sure the columns used are sortable and exist. In case of inappropriate columns or wrong syntax the table and foreign keys to it will not be created. |
|
| SDBF_ORDERBYResID | Used to override the default resource id for the ORDERBY expression. The resource id is used to extract the value from the global resource. |