You are currently reviewing an older revision of this page.
This Client Server article is republished in its entirety from 2002 for reference purposes.
By By Kees van Prooijen, Support Manager, Geographic Applications Bentley Hoofddorp 13 February 2002 MicroStation makes it possible to link elements with database records. For every database linkage, a few words are added to an element, in the form of an entity number and a mslink number. The entity number refers to a database table. The number is cross-referenced with the table name in the Mscatalog table. The mslink number refers to the record in a table. It is stored in the Mslink column and is unique per table.
Figure 1: Entity and Mslink number
Beside an entity and mslink number, (Figure 1) a linkage contains more information. To reach this additional information, key-in Analyze or select the Information icon from the Primary toolbox and then select the graphic element. Scroll the vertical bar until you see the database linkages in the dialog.
The linkages can be represented in an eight-word format (following the format used in ODBC, Oracle, Informix and other database management software). The eight-word (or two-byte) format contains the entity number in the fourth word and the mslink in the fifth and sixth words (see Figure 2).
Using older versions of MicroStation, linkages of four-word format (the DMRS format) might occur. The four-word format contains the entity number in the second word, the mslink in the third word, and the high order byte in the fourth word (see Figure 3).
Figure 2: ODBC Data Linkage Example (using the Analyze tool of MicroStation V8)
The database linkages are represented as hexadecimal numbers and must be converted to decimal prior to using the numbers to perform SQL queries on the database. This can be accomplished using a scientific calculator, as illustrated in Figure 7.
The first word of the eight-word data linkage contains the following information: 4 bits with: I The linkage is informational ("read-only") or non-informational ("read/write") R Remote linkage ID M Indicates linkage has been modified U Linkage is a user data linkage and the Linkage Class (4 bits) and the Type (8 bits).
In practice only the I-bit is used to determine whether the linkage is informational or not. Possible values are:
9007-Indicates that the linkage is informational (read-only). 1007-Indicates that the linkage is non-informational (read-write).
Figure 3: DMRS Linkage Example (using the Analyze tool of MicroStation V7)
The second word indicates the type of database linkage (ODBC, RIS, Oracle, Informix, etc.). Predefined types are:
6091-Oracle 1971-dBASE (or Xbase) 3948-Informix 3A77-Ingres 4F58-Sybase 5E62-ODBC 71FB-RIS (Used in the example shown in Figures 1 and 2.)
The third word is a secondary ID that is not used and will always be 0F81.
The fourth word is the entity number value in the mscatalog table. For example.
Figure 4: Database Setting
0002 (decimal 2) and 00012 (decimal 18)-The values of the entitynum column in the mscatalog table for the user tables.
select * from mscatalog where entitynum = 2 select * from mscatalog where entitynum = 18
The fifth and sixth words are used for the mslink value of the user attribute table. Swap the order of the fifth and sixth columns to get the hexadecimal number. For example:
009C 0000-In this example 9C forms the hexadecimal number for the mslink number 156 in decimal.
select * from where mslink = 156
3501 000C-Precede 3501 with a C to form the hexadecimal number C3501, which converts to a decimal number of 800001.
select * from
where mslink = 800001
Figure 5: Results of the command Last Attribute
After converting hexadecimal numbers to decimal using a scientific calculator and combining the fifth or sixth word, the mslink number can be used to perform SQL queries on the database.
The seventh and eighth words are used for the dastype or displayable attribute number from the corresponding displayable attribute table (DAS) table. The dastype is a number assigned to a specific SQL statement contained in a DAS table.
As with the eight-word format, the first word in the four-word format indicates whether the linkage is read/write or read only (Figure 3).
8000 (32768 decimal)-Indicates that the linkage is informational. 0000 (0 decimal) Indicates that the linkage is non-informational.
The second word represents the entity number value in the mscatalog table.
0004 (4 decimal) and 07D0 (2000 decimal)-The entitynum column has a value of 4 and 2000 in the mscatalog table.
select * from mscatalog where entitynum = 4 select * from mscatalog where entitynum = 2000
Figure 6: Results of the command GeoScripts Show_dblinks
The third word and high order byte of the fourth word are used for mslink values in the table specified in the second word. For example:
OD42 0103-In this example, precede OD42 with a 03 (the high order byte of the forth word) to form the hexadecimal number 30D42 which converts to a decimal number of 200002
where mslink =200002
With the eight-word format, four bytes are available for storing the mslink number: 232 = 0 - 4,294,967,295.
With the four-word format, three bytes are available for storing the mslink number: 224 = 0 - 16,777,215.
An informational linkage is created when the Linkage Mode is set to Informational in the database dialog. The dialog is opened from MicroStation's pull-down menu by going to Settings > Database.
Figure 7: Scientific Calculator
When an element with an informational linkage is copied, the new element will be linked to the same record in the database. A new record will be not created. However, when an element with a non-informational linkage is copied, the Linkage Mode controls whether an existing record is used or a new record is created. When set to New, all columns from the record linked to the original element are copied and a new Mslink is generated for the new element.
The MicroStation and MicroStation GeoGraphics database tools supports a number of database linkage types (Figure 4). The linkage type identifies what database server was used to generate the linkages. The linkage type for newly created linkages is controlled by the MS_LINKTYPE variable. This variable is set in the [database].cfg . The files are located in the
\Bentley\Program\MicroStation\config\database\ directory. An example of this variable setting is:
MS_LINKTYPE = ORACLE MS_LINKTYPE > ODBC MS_LINKTYPE > DMRS MS_LINKTYPE > XBASE MS_LINKTYPE > IX MS_LINKTYPE > RIS
When copying elements with 4 word DMRS linkages an 8 word linkage will be created (assuming the current linkage type is not DMRS).
In the DeveloperWare section of Select Services Online (selectservices.bentley.com/index.htm) several examples in both MDL and MicroStation BASIC are available to reformat a database linkage. The utilities include:
Chgent.bas Changes the entity number of a database linkage of an element.
CgDbLn.ma and Chgelnk.bas Changes the type of database linkage of existing graphic elements.
Infolink.bas Sets the database linkage type to non-informational.
For those who are using MicroStation GeoGraphics, some additional tools are available for working with attached database linkages. They are:
List Attributes-A key-in that shows the linkage with entity and mslink number (Figure 5).
GeoScripts Show_dblinks-A key-in available when GeoSELECTools is installed (Figure 6).
Note that the MicroStation GeoGraphics features are always informational. When you copy a featurized element, the record in the feature table is not copied.
The macro Infolink.bas available on the DeveloperWare section of SelectServices Online checks whether feature linkages are informational and sets them to informational if needed. The macro Featrpt.bas creates a report of all features in a DGN file.
A calculator can be opened from the Windows menu bar by going to Program > Accessories. You can use one of the electronic calculators in scientific mode to convert hexadecimal to decimal. Select Hex and key in the hexadecimal number. Then select Dec to convert the hexadecimal number to decimal.
Client Server Archive
MicroStation Desktop TechNotes and FAQs
An updated PDF document is available at http://communities.bentley.com/Other/Old_Site_Files/Member_Folders/m/keesps_files/74727.aspx
Bentley's Technical Support Group requests that you please confine any comments you have on this Wiki entry to this "Comments or Corrections?" section. THANK YOU!