Microsoft KB Archive/222556

= OFF2000: How to Test for a Successful PivotTable Connection =

Article ID: 222556

Article Last Modified on 6/18/2005

-

APPLIES TO


 * Microsoft Office PivotTable Component 9.0, run time

-



This article was previously published under Q222556



SUMMARY
There is no built-in method or property for the Microsoft Office PivotTable that tells you whether you have established a successful connection to your data source. This article illustrates one technique to do this.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The VBScript code in the following sample Web page illustrates how to detect whether you have made a successful connection to a data source. In this example, the PivotTable list control is named "PivotTable1", and the data source is a SQL Server named "SQLDB".

     Sub Setup_PT ' Build the connection string. constr="PROVIDER=sqloledb;DATA SOURCE=SQLDB;USERID=sa;" & _ "PASSWORD=;INITIAL CATALOG=Northwind"

' Disable error handling. on error resume next ' Connect the PivotTable to the database. PivotTable1.ConnectionString=constr

' Bind the PivotTable to a table in the database. PivotTable1.DataMember="dbo.orders" ' If the PivotTable is not connected to any data... if PivotTable1.ActiveData is nothing then

' ...Display an error message. msgbox "Connection failed."

else

' The connection was successful. Set up the PivotTable. set view=PivotTable1.ActiveView view.rowaxis.insertfieldset view.fieldsets("customerid") view.filteraxis.insertfieldset view.fieldsets("employeeid") view.dataaxis.insertfieldset view.fieldsets("orderid") end if End Sub



 

Additional query words: pivotlist

Keywords: kbinfo KB222556

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.