Connecting web/visio to SQL Database

Started by vanlanjl, December 09, 2009, 07:27:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vanlanjl

I have created an extensive Network toppolgy through Visio. I have collected all network device data and complied it into a SQL database. I then have linked the Visio to the Database. So each shape shows the correct data for it. My question is, will i need to write a code to make sure it is updated. Or will it automatically update if changes are made in the database since it is linked to it?

Jumpy

You need a VBA Sub that starts everytime you open the drawing to refresh the Link.
If you want to refresh a Link when the drawing is open, you can do it manually or use a second similar VBA Sub to do this on command.

vanlanjl

Where could i find directions on setting this up? would this work for the html version?

Visio Guy

Hi Guys,

Here's an article that will help with getting code to run when a document opens: Run VBA Code When Documents Open
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Visio Guy

Which method did you use to link shapes to the database? There are several routes in Visio. Also, which version of Visio are you using?
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vanlanjl

I am using Visio 2007 pro

A sfar as linking the data to the shapes. I have imported the databse.

I go to "Data" on the menu bar,
Link data to shapes,
Microsoft SQL Server database
then type in the sql server name and select the tables that i want.
it loads the tables
i then find the record i want and drag it to the shape i want.
all done

Jumpy

Than it could go like this:

Public Sub Refresh_Example()

    Dim vsoDataRecordset As Visio.DataRecordset
    Dim intCount As Integer

    intCount = ThisDocument.DataRecordsets.Count
    Set vsoDataRecordset = ThisDocument.DataRecordsets(intCount)
    vsoDataRecordset.Refresh

End Sub

Taken form here:
http://msdn.microsoft.com/en-us/library/ms427208.aspx