Model Dependency Example

Meta Data Services Programming

Meta Data Services Programming

Model Dependency Example

The following example demonstrates the use of both the DependsOn and UsedBy collections. These examples are written in Microsoft® Visual Basic®.

This example requires the Microsoft SQL Server™ 2000 Meta Data Services Software Development Kit (SDK).

To run this example:

  1. Create an information model FileSys.mdl that contains three packages: FileSys, FAT, and NTFS.

  2. Create three type libraries: FileSys, FAT, and NTFS.

  3. Populate the repository database (FileSys.mdb) with the type libraries by using the SDK component Inrepim.exe.

In this example the type library FileSys is used by FAT and NTFS. Also, both of the type libraries FAT and NTFS depend on the FileSys type library.

The Visual Basic Module
'----------------------- Model Dependency Example -----------------------
'Declare OBJIDs assigned to type libraries:
Public Const OBJID_TypeLib_FILESYS = "{{992CF8AC-BD64-11d2-ACBD-00C04FC2F637},0000000E}"
Public Const OBJID_TypeLib_NTFS = "{{992CF8B1-BD64-11d2-ACBD-00C04FC2F637},00000005}"
Public Const OBJID_TypeLib_FAT = "{{992CF8AF-BD64-11d2-ACBD-00C04FC2F637},00000006}"
'----------------------------- Declarations -----------------------------
Public Rep As New Repository
Dim FileSys As RepositoryObject
Dim FAT As RepositoryObject
Dim NTFS As RepositoryObject
Dim Root As RepositoryObject
Private Sub Main()
'-----------Open Repository database and set OBJIDs to objects ----------
   Set Root = Rep.Open("FileSys.mdb")
   Set FileSys = Rep.Object(OBJID_TypeLib_FILESYS)
   Set FAT = Rep.Object(OBJID_TypeLib_FAT)
   Set NTFS = Rep.Object(OBJID_TypeLib_NTFS)
'------------------------------ Transaction -----------------------------
   Rep.Transaction.Begin
   FileSys("IReposTypeLib2").UsedBy.Add FAT
   NTFS("IReposTypeLib2").DependsOn.Add FileSys
   Rep.Transaction.Commit
'-------------------------------- Cleanup -------------------------------
   Set FileSys = Nothing
   Set FAT = Nothing
   Set NTFS = Nothing
   Set Rep = Nothing
End Sub
'-------------------- End of Model Dependency Example -------------------

See Also

IManageReposTypeLib Interface

IReposTypeLib Interface

Meta Data Services SDK

ReposTypeLib Class