Presents: ObjectRoleModeling.com Wednesday, March 10, 2010
  Search
Register Login
Web Log
 
 
  Web Log Entries  
 
Feb 3

Posted by: Scot Becker
2/3/2004 

As a postscript to this tip: starting with version 1.5, the Orthogonal Toolbox will display these orphaned relationship lines via the element browser. You can then delete them directly, without running any of the following code.


Some versions of Visio contain a bug where it is possible to orphan relationship lines such that the model will fail to validate/build.

The way to do this is to drag an unattached relationship line onto the diagram, delete it, and then choose to delete it from the diagram (but not the model). Since there is not GUI way to get to this relationship line, you cannot remove it from the model. Then, the model will fail to validate so you cannot build any project that contains the given model.

This bug is fixed in the version of Visio for Enterprise Architects that is shipped with Visual Studio .Net 2003 Enterprise Architect. Further, Orthogonal Toolbox 1.5 will contain functionality to remove these orphaned relationship lines.

In the meantime, you can remove these orphaned relationships via some VBA code, as provided by Chang Oh from Microsoft:

' This is provided "AS IS" with no warranties, and
' confers no rights.
'
' This module removes all relationships that are NOT fully connected
' to either parent table or child table. The relationship may or may
' not visible. If you get
' filename : error L2100: FK name : Relationship is not fully connected.
' error messages and not able to locate it on the diagram, then this module
' will remove the relationships from the model.
'
' Follow the following steps
'
' Select "Tools"/"Macros"/"Visual Basic Editor" from the Visio menus.
' Select "Tools"/"References" from the Visual Basic editor.
' Check "Microsoft Visio Database Modeling Engine Type Library" and
' click the OK button.
' Copy this following subroutine into the text area under "(General)"
' Select "Run"/"Run Sub-UserForm" (or hit the play button)
' Close the Visual Basic editor
' Now select "Database"/"Model"/"Error Check"
'
Sub DeleteAllDisconnectedRelationshipsFromAllModels()

Dim vme As New VisioModelingEngine
Dim models As IEnumIVMEModels
Dim model As IVMEModel
Dim elements As IEnumIVMEModelElements
Dim element As IVMEModelElement
Dim relationship As IVMERelationship

Set models = vme.models
Set model = models.Next

Do While Not model Is Nothing
Set elements = model.elements
Set element = elements.Next

Do While Not element Is Nothing
If (element.Type = eVMEKindERRelationship) Then
Set relationship = element

If (Not relationship.IsFullyConnected) Then
model.DeleteElement element.ElementID
Set elements = model.elements
End If
End If

Set element = elements.Next
Loop

Set model = models.Next
Loop
End Sub

Tags:

Bookmark and Share
 

Note: To comment on a blog post, you must be logged in.

  Search Web Log  
 
 
  Subscribe Minimize  
 
Subscribe
 
  Categories  
   
  Archive  
   
  Blog Roll  
   
  Syndication  
   
 
© 2003 - 2009 Orthogonal Software Corporation. All rights reserved. Terms Of Use Privacy Statement