Microsoft KB Archive/268836

= 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 &quot;same domain&quot; 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:

http://msdn.microsoft.com/dataaccess

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.     





 Sub Window_onLoad PivotControl1.AutoFit = false PivotControl1.height = &quot;80%&quot; PivotControl1.width = &quot;100%&quot; ConnectToDB End Sub

Sub ConnectToDB 'SQL query sSql = &quot;Select * from Orders&quot;

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

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

'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,&quot;PivotData&quot; End if    'Set the DataSource property of the PivotTable Component set PivotControl1.DataSource = dsc.object

PivotControl1.DataMember = &quot;PivotData&quot; 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 &quot;Query complete&quot; End Sub



 </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

<div class="references_section">