Microsoft KB Archive/268836

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 11:36, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


How To Use the Office DataSource Component with RDS to Avoid Cross-Domain Warnings

Article ID: 268836

Article Last Modified on 7/13/2004



APPLIES TO

  • Microsoft Office PivotTable Component 9.0
  • Microsoft Office Spreadsheet Component 9.0



This article was previously published under Q268836

SUMMARY

The Office DataSource Component (DSC) displays the following cross-domain warning message when accessing data from a domain other than the one from which a Web page originates:

This page accesses data from another domain. Do you want to allow this?

This warning message is displayed because the DSC, which is marked safe for initialization and scripting, may potentially be used to access and modify data maliciously under the security context of an unsuspecting user. If a user trusts the source of a Web page, that user can suppress cross-domain warnings by adding the site to his or her trusted site list in Microsoft Internet Explorer.

However, if you, as a developer, do not want your users to receive cross-domain warnings while accessing your Web pages that use the DSC, you can use Microsoft Remote Data Services (RDS) to run commands and fetch data remotely on your Web server so that the "same domain" condition is satisfied.

This article describes how to use RDS with the Microsoft Office DataSource Component for the purpose of suppressing cross-domain warnings.

MORE INFORMATION

Remote Data Service (RDS) is used to transport disconnected Microsoft ActiveX Data Object (ADO) recordsets from a server to a client computer. The resulting recordsets are cached on the client computer and disconnected from the server. RDS performs the caching and remoting over HTTP. You can download RDS server and client components from the Microsoft Universal Data Access page at:

With the DSC, you can use the RDS provider by setting its UseRemoteProvider property to True (the default value is False). When UseRemoteProvider is set to True, the DSC alters the connection string to use the RDS provider. However, RDS still uses the OLE DB provider remotely to fetch the data. Therefore, the RDS provider needs the following information to retrieve the data:

  • The name of the Web server where the RDS server components are installed.


-and-

  • The name of the real data provider that RDS uses on the Web server.

Sample

The following HTML sample demonstrates the use of RDS with an Office DataSource component bound to an Office PivotTable. RDS is used to access data from the sample Northwind.mdb database without cross-domain warnings.

<HTML>
<HEAD>
<TITLE  "OWC Data Source Component with RDS "></TITLE>
</HEAD>
<BODY>

<!-- OWC Data Source Component for getting at the data -->
<object classid="clsid:0002E530-0000-0000-C000-000000000046" id="dsc" width="1" height="1" VIEWASTEXT>
</object>

<!-- PivotTable Component for displaying the data -->
<OBJECT classid="clsid:0002E520-0000-0000-C000-000000000046" id="PivotControl1" height="518"  width="518" VIEWASTEXT></OBJECT>

<SCRIPT language=VBScript>
Sub Window_onLoad()
 PivotControl1.AutoFit = false
 PivotControl1.height = "80%"
 PivotControl1.width = "100%" 
 ConnectToDB
End Sub

Sub ConnectToDB()
     'SQL query
     sSql = "Select * from Orders"

     'Set the Connection string 
     strconnect = "PROVIDER=microsoft.jet.oledb.4.0;"

     'Specify the proper database path on the server
     strconnect = strconnect & "DATA SOURCE=" & _
           "C:\Program Files\Microsoft Office\Office\Samples\Northind.mdb;"

     'Set the UseRemoteProvider property to True to make the necessary 
     'modifications to the connection string
     dsc.UseRemoteProvider = true

     'Set the connection string property
     dsc.connectionstring = strconnect

     'Add the Recordset Definition only once. This will help when the user  
     'refreshes the page

      If dsc.RecordsetDefs.Count = 0 Then
      'Add the SQL statement to the Recordset definitions
         dsc.RecordsetDefs.AddNew sSql,dsc.Constants.dscCommandText,"PivotData"
      End if
 
     'Set the DataSource property of the PivotTable Component
     set PivotControl1.DataSource = dsc.object

     PivotControl1.DataMember = "PivotData"
     
     set pview = PivotControl1.ActiveView 
     pview.AutoLayout  
     pview.FilterAxis.label.visible = false
     pview.RowAxis.label.visible = false
     pview.ColumnAxis.label.visible = false
     pview.titlebar.visible = false
     
End Sub 

Sub PivotControl1_QueryComplete()
    MsgBox "Query complete"
End Sub 

</SCRIPT></P>

</BODY>
</HTML>

To use the sample, copy it to an HTML file in a Web folder, such as the default Microsoft Internet Information Services (IIS) home directory C:\inetpub\wwwroot, and navigate to the HTML file by using an HTTP protocol. If the HTML file is not saved to a Web folder, or if you try to invoke it by double-clicking in Windows Explorer, you may receive the following error message:

The UseRemoteProvider property is supported only for pages saved to webfolders.

RDS requires HTTP or DCOM for remoting. Failure to invoke the HTML without either of these may result in an error.

For additional information about troubleshooting problems with RDS, click the article number below to view the article in the Microsoft Knowledge Base:

251122 Troubleshooting Common Problems with Remote Data Services


REFERENCES

Programming Microsoft Office 2000 Web Components by Dave Stearns, ISBN 0-7356-0794-X, Chapter 5.

For additional information on deploying your solutions that use the Office 2000Web components, click the article numbers below to view the articles in the Microsoft Knowledge Base:

243006 OFF2000: Licensing Office Web Components and Server Extensions


258510 INFO: Office Web Components Display Cross-Domain Warning




Keywords: kbhowto kbofficewebchart kbpivottable kbofficewebpivot KB268836