Please, help me with a COMException on the OWC Chart control

R

roger.camargo

Well the idea is imple, creating a chartspace bound to a cube file.
When inserting a Category to the chart it throws a COMException

AxChartSpace chartSpace;
chartSpace = new AxChartSpace();
Controls.Add(chartSpace);
chartSpace.ConnectionString = @"Provider=MSOLAP.2;Persist
Security Info=False;Location=C:\example.cub;Initial
Catalog=example;Client Cache Size=25;Auto Synch Period=10000";
chartSpace.DataMember = "example";
ChChart chart = chartSpace.Charts[0];
chart.SetData(ChartDimensionsEnum.chDimCategories,

(int)ChartSpecialDataSourcesEnum.chDataBound,
"Time");

The exception is the following:

Message = "Error HRESULT E_FAIL has been returned from a call to a COM
component."
Source = "Microsoft.Office.Interop.Owc11"
StackTrace = "
at
Microsoft.Office.Interop.Owc11.ChChart.SetData(ChartDimensionsEnum
Dimension, Int32 DataSourceIndex, Object DataReference)
at WindowsFormsApplication5.Form1.button3_Click(Object sender,
EventArgs e) in C:\Documents and Settings\Jhonny\My Documents\Visual
Studio 2008\Projects
\WindowsFormsApplication5\WindowsFormsApplication5\Form1.cs:line
39 ..."
TargetSite = "{Void
SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum, Int32,
System.Object)}"

Does anyone here try to do the same as me, in .NET and make it work?
How? Can someone send me the OWC wrappers (maybe that's what's wrong)?

Please I'm loosing my mind T.T !!!
 
R

roger.camargo

I've forgot to write that I'd had tested to do the same with a Web
Page, and it worked:

<BODY onload=initOwc() topmargin="0" leftmargin="0">
<object id="chart"
CLASSID="CLSID:0002E556-0000-0000-C000-000000000046" width=100%
height=100%>
</object>

<SCRIPT LANGUAGE="VBscript">
sub initOWC
chart.connectionstring = "Provider=MSOLAP.2;Location=C:\
\examplecub;Initial Catalog=example;"
chart.datamember = "example"
chart.setdata 1,0, "Time"
end sub
</SCRIPT>
</BODY>

by the way it's not an enumeration problem cuz I'd tested
chDimCategories = 1 and chDataBound = 0

Thanks to anyone that can help, and to those that took the time to
read this.
 
R

roger.camargo

OK, I've got the answer:
ChChart chart = chartSpace.Charts[0]; //<---------------this is not
correct
chart.SetData( ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataBound,
"Time");


The right way would be:
chartSpace.SetData( ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataBound,
"Time");

Ok, with this, the Year, an Month field apear at the Categories, but
Month isn't exoanded, how can I expand it?
 
Top