PivotTables with non-cube ADO Tables (OWC11)

S

Simon

Hi,

I'm having some problems getting PivotTables to work when attached to
bog-standard tables (rather than SSAS cubes).

Here's what I can determine so far (with a really simple, 3 field,
single table source)

-> The recordset is being created fine, and does have valid data in it.
-> The pivottable is 'aware' of the table structure because when I
examine .XMLData after if added stuff to it, it contains <x:pivotField>
elements corresponding to the fields in the underlying table.
-> But the XMLData does not contain any real data - it's like it's
aware of the structure but can't see the data.

In most of the examples (against SSAS/OLAP) there is a .DataMember
property that references the source cube. What (if anything) to I put
in here for a vanilla table? That's about the only thing I can come up
with as a problem so far. Leaving it as Nothing results in a runtime
error, setting it to Book3 (the source table) doesn't seem to do much
either. I could also have missed a step in my AddPivotRow().

Perhaps some code would help. I might add that my copy of the Black
Book has been ordered, but any pointers to get me started pending its
arrival (and unless I'm being really dense it does not seem to be
offered as a download) would ease my pain. Apologies on the longish
post, but I'd rather add everything that I think is relevant at the
start.

Regards

Simon

oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO

Dim pt As PivotTable = New PivotTableClass
Dim conn As ADODB.Connection = New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SQL As String = "SELECT AccessLevel, LMGPIN, FunctionType
FROM book3"

With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source='C:\Documents and Settings\Simon\My Documents\Visual Studio
2005\WebSites\owc2\App_Data\db1.mdb'"
.Open()
End With

rs.Open(SQL, conn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)
With pt
.ConnectionString = conn.ConnectionString
.CommandText = SQL
.DataSource = rs
.DataMember = ""

With .ActiveView
.AutoLayout()

Dim Fields As String() = {"AccessLevel", "LMGPIN",
"FunctionType"}
AddPivotRows(pt, Fields)
End With

End With
TheXml = pt.XMLData

Where AddPivotRows is defined as

Private Sub AddPivotRows(ByVal PivotTable As PivotTableClass, ByVal
Fields As String())
Dim av As PivotView = PivotTable.ActiveView

For Each FieldToAdd As String In Fields
Dim fs As PivotFieldSet = av.FieldSets(FieldToAdd)
av.RowAxis.InsertFieldSet(fs)

With fs.Fields(FieldToAdd)
.IsIncluded = True
End With
Next

The resulting .XMLData is as follows

<x:pivotTable>
<x:OWCVersion>11.0.0.6555 </x:OWCVersion>
<x:NoDisplayAlerts/>
<x:DisplayScreenTips/>
<x:CubeProvider>msolap.2</x:CubeProvider>
<x:CacheDetails/>
<x:Name>Microsoft Office PivotTable 11.0</x:Name>
<x:NoColumnGrand/>
<x:DataAxisEmpty/>
<x:pivotField>
<x:Name>AccessLevel</x:Name>
<x:Orientation>Row</x:Orientation>
<x:EncodedType>adVarWChar</x:EncodedType>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
<x:Subtotal>None</x:Subtotal>
<x:Expanded/>
</x:pivotField>
<x:pivotField>
<x:Name>LMGPIN</x:Name>
<x:DataType>Integer</x:DataType>
<x:Orientation>Row</x:Orientation>
<x:position>2</x:position>
<x:EncodedType>adInteger</x:EncodedType>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
<x:Subtotal>None</x:Subtotal>
<x:Expanded/>
</x:pivotField>
<x:pivotField>
<x:Name>FunctionType</x:Name>
<x:Orientation>Row</x:Orientation>
<x:position>3</x:position>
<x:EncodedType>adVarWChar</x:EncodedType>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
<x:Expanded/>
</x:pivotField>
<x:pivotField>
<x:Name>Data</x:Name>
<x:Orientation>Column</x:Orientation>
<x:position>-1</x:position>
<x:DataField/>
</x:pivotField>
<x:pivotView>
<x:IsNotFiltered/>
</x:pivotView>
</x:pivotTable>
</xml>
 
S

Simon

Hi,

Given the deafening silence here :) I've taken a different approach,
and implemented data-retrieval through via the webservice approach as
outlined in http://support.microsoft.com/?id=315695. In my particular
environment this will probably turn out to be more useful but I'd
initially felt that it added a layer of complexity that I could do
without while trying to get to grips with the components. Guess I was
wrong!

Still don't know why direct ADO retrieval wasn't going, but I'm not
going to lose sleep over it either now I have a work around. Hope this
is of some help to someone.

Regards

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top