Page 1 of 1

Can I pass a disconnected recordset to a crosstab source

Posted: Wed Sep 14, 2005 2:43 am
by 9524925
Hello,
I would like to pass a recordset to crosstab source object.
Something like:

set rs = new adodb.recordset
rs.fields.append("grp", ...)
rs.fields.append("lbl", ...)
rs.fields.append("val", ...)
for i = 0 to ...
rs.addnew
rs(0).value = g(i): rs(1).value = l(i): rs(2).value = v(i)
next i
rs.batchupdate
'crosstabsource.datasource = rs

is it possible?

Yours

Carlos

Posted: Wed Sep 14, 2005 11:30 am
by narcis
Hola Carlos,

Yes, this is possible. For more information on how to use TeeChart with databases please read "Tutorial 8 - ADO Database access" and have a look at the features demo examples (All Features\Welcome!\Database Charts). You'll find the tutorials and features demo at the TeeChart program group.

Posted: Thu Sep 15, 2005 12:09 am
by 9524925
Hi Narcis,

Thansk for your reply, Unfortunately that's not what I want. I want to use the crosstab source object and not the ADODB support of the chart object.
The problem is that I don't know how many series and points I have beforehand.

Is it possible?

Thanks again

Carlos

Posted: Mon Sep 19, 2005 9:22 am
by Pep
Hi Carlos,

you cannot pass a recordset directly to the CrosstabSource, that I know of. It can be only used as in the DB CrossTab source example, using similar code to the following :

Code: Select all

Private Sub Form_Load()
  With CrossTabSource1
    .DataSet = "DSN=TeeChart Pro Database; SQL=select * from orders"
    .Series = TChart1.Series(0)
    .GroupField = "Terms"
    .LabelField = "PaymType"
    .ValueField = "AmntPaid"
  End With
End Sub
But, you can always generate the recordset, iterate through it and then add data manually to the Chart Series using the AddXY method.