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:
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.
'----------------------- 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 -------------------