Re: How can I tell what table a recordset is bound to?
- From: "Joseph Geretz" <jgeretz@xxxxxxxxxx>
- Date: Wed, 27 Jul 2005 12:09:07 -0400
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 -
>
>
>
.
- References:
- How can I tell what table a recordset is bound to?
- From: Joseph Geretz
- How can I tell what table a recordset is bound to?
- Prev by Date: Re: Tools for record locking in MS Access
- Next by Date: Can this small function be sped up? VB6 COM ADO (2.8) question...new to this stuff!
- Previous by thread: Re: How can I tell what table a recordset is bound to?
- Next by thread: Accessing filenames programatically
- Index(es):
Relevant Pages
|
|