Page 1 of 1

using Series->DataSource from C++

Posted: Fri Feb 15, 2008 4:04 pm
by 9528318
Hi,

i am trying to connect my series to a mysql datasource (TeeChart 7 Activex). For MySQL I create an ADO recordset through the MySQL ODBC driver.

i am using TeeChart from a #import statement.

Code: Select all

#import <msado15.dll> rename("EOF", "EndOfFile")
#import "C:\Program Files\TeeChart7\TeeChart7.ocx"

_COM_SMARTPTR_TYPEDEF(_Recordset, __uuidof(_Recordset));

_RecordsetPtr recordset = ...;
CString sql(_T("SELECT * FROM measurements limit 200"));
recordset->Open(sql);

CWnd * pteechart = ...;

ITChartPtr teechart = pteechart->GetControlUnknown();
_variant_t v((LPUNKNOWN)recordset);
long serie = teechart->AddSeries(scLine);
ISeriesPtr pserie = teechart->Series(serie);
pserie->DataSource = v;
pserie->LabelsSource = "DateTimeID";
pserie->XValues->ValueSource = "DateTimeID";
pserie->XValues->DateTime = TRUE;
pserie->YValues->ValueSource = "RelativeTime";
this gives me a runtime error, what is the good way to do this ? What type does the pserie->DataSource expect ?

Posted: Fri Feb 15, 2008 4:22 pm
by narcis
Hi xpar,

You'll find an example at C:\Program Files\Steema Software\TeeChart Pro v7 ActiveX Control\Examples\Visual C++\Version 6\ADO Single Record. More information can also be found at Tutorial 15 - MS VC++ Applications. You'll find the tutorials at TeeChart's program group.

Hope this helps!

Posted: Mon Feb 18, 2008 9:25 am
by 9528318
Thanks, I changed to

Code: Select all

_variant_t v((LPDISPATCH)recordset);
and it worked!