using an unbound ADO recordset with the PivotTable

L

lubelabbe

We need to use the PivotTable on in-memory data, not data stored in a
database.

The PivotTable control works fine when it's DataSource property is
bound to an ADO recordset that is connected to a database.

However, the the DataSource property assignment fails when trying to
assign an Unbound ADO recordset. It complains that the Interface is not
supported and throws an InvalidCastException.

....
pivotAsset.DataSource = (msdatasrc.DataSource)m_ADOData; <-- Fails
here.
....

The Unbound ADO recordset is set up ok because we can bind it controls
without problems. Also, this is the first problem that has appeared
anywhere in our project (for the Unbound ADO recordset - we have had
lots of other problems :).

Any help would be appreciated ?

Michael
 
A

Alvin Bruney [MVP]

What is the return datatype? I don't think it should matter if it is
unbounded as long as it implements the idatasource interface it should work.
 
L

lubelabbe

Alvin,

Thanks for answering.

Just knowing that it should be possible helped a lot. We discovered
that the assembly was using ActiveX Data Object 2.1. Changing to 2.8
solved the problem. Now we'd like to know how that 2.1 reference ended
up in the reference list (but that's for another day....).

Michael
 
L

lubelabbe

Just another thought ...

Is is possible to bind directly to an IList ? Currently, we are copying
data into the recordset which creates an extra intermediate (and
unnecessary) copy.
 
A

Alvin Bruney [MVP]

yup, it should work once the datasource implements ilistsource not ilist
 
L

lubelabbe

No luck.

We added IListSource to the in-memory data object which already
implements IList. The data object has been bound to a lot of other
controls (ChartFX, Janus Winforms, etc...) without problems so the
IList implementation seems ok.

....
#region IListSource
public Boolean ContainsListCollection
{
get
{
return false;
}
}

public IList GetList()
{
return this;
}
#endregion
....

We had to implement the msdatasrc.datasource interface so that the data
object could be assigned to the PivotTable's DataSource property. We
winged this implementation since there doesn't seem to be any doco on
the interface (although it is simple and we ignored the Listener
options for now).

....
#region MSDataSrcDataSource
void
msdatasrc.DataSource.addDataSourceListener(msdatasrc.DataSourceListener
pDSL)
{
}

System.Object msdatasrc.DataSource.getDataMember(System.String
bstrDM, ref System.Guid riid)
{
return this;
}

System.Int32 msdatasrc.DataSource.getDataMemberCount()
{
return 1;
}

System.String msdatasrc.DataSource.getDataMemberName(System.Int32
lIndex)
{
return Title;
}

void
msdatasrc.DataSource.removeDataSourceListener(msdatasrc.DataSourceListener
pDSL)
{
}
#endregion
....

Anyway, the data object casts fine but then an ExecutionEngineError is
thrown inside the control a bit later (before it is displayed).

We tracked with breakpoints and the problem appears to happen after the
getDataMember call. Should this function be returned the IListSource
enabled object or something else ?

Any thoughts ?

Also, OWC is incredible. Glad we stumbled on to it. Alvin, if you know
one of the developers then please say thanks.
 
A

Alvin Bruney [MVP]

ExecutionEngineError ?
is this coming from the CLR? That's a bug and needs to be reported.
 
L

lubelabbe

It was actually ExecutionEngineException, not ExecutionEngineError. It
bubbles up to the top Application loop and neither the stack or the
output window gives any indication from where it came. No breakpoints
or try blocks can placed in our code to trap the error
(although we have not been exhustive yet).

How does the bug get reported and what info is needed ? Binding an
IList to the PivotTable control solves a huge performance penalty for
us so we'll do anything to help get it sorted out.
 
A

Alvin Bruney [MVP]

well one at a time. can you give me a small reproducable sample with the
executionengineexception?

catch blocks will not catch and finally blocks will not execute when that
type of error. engine exceptions are thrown when the CLR detects instability
within itself which is why i would like to get this reported. see this link
for a small reproducible sample
http://www.yoda.arachsys.com/csharp/complete.html

You will need to implement IListSource NOT IList. Don't get the two
confused.
Here is a starter link
http://msdn.microsoft.com/library/d...systemcomponentmodelilistsourceclasstopic.asp
 

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