CanQuery Property
Returns True if the XmlDataBinding object (as specified in the <Binding> element in the XML Spreadsheet file) contains a child <DataSource> element with a Purpose
attribute (/Binding/DataSource/ConnectionInfo@Purpose) that has the value "Query". Otherwise it returns False.
Read-only.
expression .CanQuery
expression Required. An expression that returns an XmlDataBinding object.
Remarks
If True is returned, the Purpose
attribute of the <DataSource> element has the value "Query". This means you can call the Refresh method of the XmlDataBinding object to requery the data source. Note that an XMLDataBinding object can contain more than one <DataSource> element tag: one in which Purpose
has the value "Query" and one in which Purpose
is "Update". For information on update bindings, see the CanUpdate property.
An XMLDataBinding object represents a binding to an XML file, a SOAP service, another Web part (only when binding from a Spreadsheet Web Part), or a data retrieval service connection.
The XML fragment where the <DataSource> element details appear in the XML Spreadsheet file looks something like the following:
<x2:Binding x2:ID="Cust_bind_id" x2:LoadMode="Normal" x2:Async="False">
<x2:MapID>Cust_MapId</x2:MapID>
<udc:DataSource MajorVersion="1" MinorVersion="0">
<udc:Type Type="XMLFile" MajorVersion="1" MinorVersion="0"/>
<udc:Name>sample_name</udc:Name>
<udc:ConnectionInfo Purpose="Query">
...
</udc:ConnectionInfo>
</udc:DataSource>
Example
The following example attempts to refresh a binding. This will cause an event handler for the BindingCompleted event to run, which determines whether a binding can be queried (that is, whether its Purpose
attribute has the value "Query"). You can write code in the event handler to perform any additional actions on the binding.
Sub RefreshBinding(Spreadsheet1)
Dim objBinding
Set objBinding = Spreadsheet1.ActiveWorkbook.XmlDataBindings("Cust_bind_id")
objBinding.Refresh
End Sub
Sub Spreadsheet1_BindingCompleted(bindingID, Action)
If Spreadsheet1.ActiveWorkbook.XmlDataBindings.Item(bindingID).CanQuery = True Then
' Write code here to perform any additional actions on this query binding.
End If
End Sub
Note For information on trapping the BindingCompleted event from script running in a Web page, see the BindingCompleted event topic.