Microsoft Office Tutorials and References
In Depth Information
Listing 2-8. Using Visual Basic for Applications to Retreive Data from a SQL Server Data Source
Sub LoadData()
Dim diagramServices As Integer
Dim vsoDataRecordset As Visio.dataRecordset
Dim connectionString As String
Dim commandText As String
diagramServices = ActiveDocument.DiagramServicesEnabled
ActiveDocument.DiagramServicesEnabled = visServiceVersion140
Application.ActiveWindow.Windows.ItemFromID(visWinIDExternalData).Visible = True
commandText = "SELECT ServerName, ServerIP, ServerStatus FROM tblServerStatus"
connectionString = "Provider=SQLOLEDB;Data Source=<YourDataSourceName>;
Initial Catalog=VisioServices;Integrated Security=SSPI;"
Set vsoDataRecordset = ActiveDocument.DataRecordsets.Add(
connectionString, commandText, 0,
"Server Status Details")
vsoDataRecordset.DataConnection.connectionString =
"DataModule=DataModules.VisioDataProviderService,
VisioDataProviderService;"
ActiveDocument.DiagramServicesEnabled = diagramServices
End Sub
the following code is explained toward the end of this chapter in the section “Understanding the Custom Data
provider Code.” You need to customize the connection string and the Data module assembly details in the following code.
Note
39.
the Microsoft Visual Basic for applications window should look like the one in Figure 2-80 .
Figure 2-80. Microsoft Visual Basic for Applications
 
 
Search JabSto ::




Custom Search