Re: How can I tell what table a recordset is bound to?



Here's how I've solved this (code below):

Now I like a nifty bit of code as much as the next guy. However, if there's
a documented way to get at this information through the Recordset interface
itself, then I wouldn't have to be hacking around in the XML for this
information, and clearly that would be the way to go. But if there is no
interface to get at this information which is clearly maintained in the
Recordset, I'd like to ask any Microsoft monitors on this newsgroup - why
not?

Thanks,

- Joe Geretz -

Public Function RecSetBinding(RS As Recordset, Optional Simple As Boolean =
True) As Variant

Dim XDOM As MSXML2.DOMDocument40
Dim XAttribs As MSXML2.IXMLDOMNodeList
Dim Table As String

Dim RSBindings As Recordset
Dim MU As MiscUtils
Dim lX As Long

Set XDOM = RecSetToXML(RS)

Set XAttribs = XDOM.getElementsByTagName("s:AttributeType")

If Simple = True Then

On Error Resume Next ' just return empty string if attribute not
available
Table = XAttribs.Item(0).Attributes.getNamedItem("rs:basetable").Text
RecSetBinding = Table
Exit Function

Else
Set MU = New MiscUtils
Set RSBindings = MU.ADORecSet("Name|Database|Table|Column")
Set MU = Nothing

For lX = 0 To XAttribs.Length - 1
RSBindings.AddNew
RSBindings("Name") =
XAttribs.Item(lX).Attributes.getNamedItem("name").Text
On Error Resume Next ' just return empty string if attribute not
available
RSBindings("Database") =
XAttribs.Item(lX).Attributes.getNamedItem("rs:basecatalog").Text
RSBindings("Table") =
XAttribs.Item(lX).Attributes.getNamedItem("rs:basetable").Text
RSBindings("Column") =
XAttribs.Item(lX).Attributes.getNamedItem("rs:basecolumn").Text
On Error GoTo 0
Next lX

Set RecSetBinding = RSBindings
Exit Function

End If

End Function

"Joseph Geretz" <jgeretz@xxxxxxxxxx> wrote in message
news:%23xnZwgikFHA.2724@xxxxxxxxxxxxxxxxxxxxxxx
> How can I tell what Table a disconnected recordset is (logically) bound
> to?
>
> OK, I know that strictly speaking the question doesn't make sense, since
> the
> truth is a recordset might possibly be updatable to multiple tables
> (subject
> to driver support). But knowing what I do know about our own recordsets,
> I'd
> be satisfied with the Table binding for the first column and I'd be happy
> enough to work off the assumption that all columns are updating to the
> same
> table.
>
> I can see in the XML representation of the recordset that there is a table
> attribute for each column definition:
>
> <s:AttributeType name="DOCUMENTGROUPDESC" rs:number="1" rs:nullable="true"
> rs:writeunknown="true" rs:basecatalog="FreedomDemo"
> rs:basetable="DOCUMENTGROUP" rs:basecolumn="DOCUMENTGROUPDESC">
>
> If I have to, I can get this information by serializing the recordset to
> XML
> and using the XML DOM to find the basetable attribute for the first
> column.
> But if this is available as part of the XML representation, I'd assume
> that
> there should be some recordset or field property which would expose this.
> Is
> there?
>
> Thanks!
>
> - Joe Geretz -
>
>
>


.



Relevant Pages

  • Re: Copy Recordset
    ... Dim xml As MSXML2.DOMDocument, ... If what you need are two copies of the same recordset that are independant ... Set rst = New ADODB.Recordset ...
    (microsoft.public.vb.database.ado)
  • Re: For XML -> ADO Recordset
    ... The xml you are getting is not a persisted recordset it is simply pure xml ... Dim oCmd As Command ... Dim rs As New ADODB.Recordset ...
    (microsoft.public.sqlserver.xml)
  • Re: How to Programmatically Export as XML & SXL
    ... Unfortunately, I've had precious little to do with XML in Access, so I'm ... you use the ADO Recordset object's Save ... >>Dim rs As ADODB.Recordset ... >>Dim strADTGFile As String ...
    (microsoft.public.access.externaldata)
  • Re: MDAC Converting Dataset to XML
    ... I hadn't realised there was a later version of MDAC than the one we had ... recordset is fine, the code that does this is a mirror of the conversion to ... XML and for completeness I include a copy (albeit ... Can you reproduce the symptom by saving the first piece of xml to a file, ...
    (microsoft.public.data.ado)
  • Re: Database + dll
    ... You can include an XML or ADTG persisted Recordset with the ... XML can be compiled into a DLL as a resource, ... copied to a stream first anyway (not that the recordset would alter the ... It's a simple matter of creating a custom resource type from an XML file at ...
    (microsoft.public.vb.database.ado)