DataRecordsets.GetLastDataError method (Visio)
Gets the Active X Data Objects (ADO) error code, ADO description, and data recordset ID associated with an error that results from adding a new data recordset or refreshing the data in an existing one.
Note
This Visio object or member is available only to licensed users of Visio Professional 2013.
Syntax
expression.GetLastDataError (DataErrorCode, DataErrorDescription, RecordsetID)
expression An expression that returns a DataRecordsets object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
DataErrorCode | Required | Long | Out parameter. The ADO error code of the last error. |
DataErrorDescription | Required | String | Out parameter. The ADO description of the last error. |
RecordsetID | Required | Long | Out parameter. The ID of the data recordset that generated or triggered the error. |
Return value
Nothing
Remarks
Data-related operations that can generate ADO errors in Microsoft Visio include adding a new DataRecordset object to the DataRecordsets collection of the active document and refreshing the data in an existing data recordset.
If a data-related operation is successful, the GetLastDataError method returns RecordsetID = 0, DataErrorCode = 0, and DataErrorDescription = "" (an empty string).
If attempting to add a data recordset generates an error, the method returns RecordsetID = 0, as well as the error code and description.
If attempting to refresh the data in an existing data recordset causes an error, and if Visio knows which data recordset caused the error, GetLastDataError returns the ID of the data recordset.
It is possible, however, that Visio may not know specifically which data recordset generated the error. This can only happen when you attempt to refresh a data recordset that is one of a group of data recordsets that share the same connection to a data source. This is because when data in one data recordset in such a group (called transacted datarecordsets) is refreshed, all the data recordsets in the group are refreshed. In this situation, if the refresh operation fails before all datarecordsets in the group are refreshed, Visio rolls back the refresh of any datarecordsets successfully completed up to that point.
If you then call GetLastDataError, the method returns the following:
The ID of the data recordset on which you called the Refresh method to start the refresh operation that subsequently failed.
The error message generated by the failed refresh operation, although there is no way to know if the failure was specifically related to the data recordset whose ID you passed to the GetLastDataError method.
Example
The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the GetLastDataError method to get the ADO error code and description and the data recordset ID associated with the last data error.
Public Sub GetLastDataError_Example()
Dim vsoDataRecordsets As Visio.DataRecordsets
Dim lngCode As Long
Dim strDescription As String
Dim lngID As Long
Set vsoDataRecordsets = Visio.ActiveDocument.DataRecordsets
vsoDataRecordsets.GetLastDataError lngCode, strDescription, lngID
Debug.Print "Error code: ", lngCode
Debug.Print "Error description: ", strDescription
Debug.Print "Data recordset ID: ", lngID
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.