CanUpdate Property

Microsoft Office Web Components Visual Basic

CanUpdate Property

Returns True if the XmlDataBinding object (as specified by the <Binding> element in the XML Spreadsheet file) contains a <DataSource> element with a Purpose attribute (/Binding/DataSource/ConnectionInfo@Purpose) that has the value "Update". Otherwise it returns False. Read-only.

expression .CanUpdate

expression    Required. An expression that returns an XmlDataBindingobject.

Remarks

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 details appear in the XML Spreadsheet file looks something like the following:

      <udc:DataSource MajorVersion="1" MinorVersion="0" xmlns:udc="http://schemas.microsoft.com/data/udc">
   <udc:Type Type="XMLFile" MajorVersion="1" MinorVersion="0"/>
   <udc:Name>Example_Filename<udc:Name/> 
   <udc:ConnectionInfo Purpose="Update">
      ...
   </udc:ConnectionInfo>
</udc:DataSource>
    

Example

The following example first determines wheter a data retrieval service connection binding can be updated (that is, whether its Purpose attribute has the value "Update"). If so, the code calls the UpdateBinding function, passing in the BindingId attribute value as the argument. Because update bindings are always performed synchronously, there is no need to check if the binding is asynchronous, and the function calls the Update method immediately.

    Dim objBinding

Set objBinding = Spreadsheet1.ActiveWorkbook.XmlDataBindings("Cust_bind_id")
    If objBinding.CanUpdate = True Then
        ' Fetch the data and update the corresponding map.
        UpdateBinding("Cust_bind_id")
    End If
        
Next

Function UpdateBinding(strBindingID)
    Dim objBinding
    
    Set objBinding = Spreadsheet1.ActiveWorkbook.XmlDataBindings(strBindingID)

    objBinding.Update
End Function