Page 1 of 1

Getting the DataSource Info out of chart

Posted: Fri Sep 25, 2009 12:53 am
by 15047219
I seem unable to get the DataSource decoded from a VARIANT

VARIANT DataSrc = m_Chart.Series(0).GetDataSource();
// Ok now what

I'd like to get the connection string out and what the axis value string are set to.

Thanks

Re: Getting the DataSource Info out of chart

Posted: Fri Sep 25, 2009 3:55 pm
by narcis
Hi jfrancis,

What are you exactly trying to achieve with that? If you want to get axes labels you'd better use OnGetAxisLabel or OnGetNextAxisLabel event. For more information about that please read tutorial 4.

Hope this helps!

Re: Getting the DataSource Info out of chart

Posted: Mon Sep 28, 2009 4:42 pm
by 15047219
Sorry was was not clear.

I'm not interested in the Axis-Label, that is ok at my end.

What I'm after is to look at the contents of the DataSource, it is returned as a VARIANT data type, see "VARIANT DataSrc = m_Chart.Series(0).GetDataSource();"

I am unsuccessful in converting it into an ADO (ADODB::_ConnectionPtr) object so that I can read the "connection string" and
the ADO (ADODB::_RecordsetPtr) to get the "source" or SQL command string.

I am working in C++ and MFC if this helps.

Thanks,
John Francis

Re: Getting the DataSource Info out of chart

Posted: Mon Oct 05, 2009 9:47 am
by yeray
Hi John Francis,

We've investigated it but I'm afraid we don't see a way to retrieve this information with TeeChart AX.

Re: Getting the DataSource Info out of chart

Posted: Tue Oct 06, 2009 3:45 pm
by 15047219
I got some of the info I needed see source code below:

//|----------------------------------------------------------------------------
void CTest_TChart_DB_Load_vADlg::DisplaySourceStr(void)
{
VARIANT vrDataSrc = m_Chart.Series(0).GetDataSource();
ADODB::_RecordsetPtr aRecordSet = (_variant_t)vrDataSrc;
_variant_t var;
var = aRecordSet->GetSource();
CString strSource = (_bstr_t(var.bstrVal));
// Source String
CString sourcestr;
sourcestr.Format("Source: %s", strSource );
m_Source.SetWindowText( sourcestr );

_variant_t varConnect;
varConnect = aRecordSet->GetActiveConnection();
ADODB::_ConnectionPtr aConnection = (_variant_t)varConnect;

CString strConn = aConnection->GetConnectionString();

CString connstr;
connstr.Format("Connection String:\n %s", strConn);
int count = connstr.Replace( _T(";"), _T(";\r\n") );



m_ConnEditCtrl.SetWindowText( connstr );
}

Re: Getting the DataSource Info out of chart

Posted: Wed Oct 07, 2009 8:32 am
by yeray
Hi jfrancis,

Thank you for your feedback. It may help another user with a similar problem in the future.