OWC11 chartspace with a recordset in asp, and error 80004005

R

r7dis8qh

I'm trying to use OWC11 generate a chart from an ado recordset and
receive error '80004005' (with no other details) on the following line
of code:

oChartSpace.Charts(0).SeriesCollection(0).SetData
oChartConstants.chDimCategories, 0, "Agent"


in the following context:

Set oChart = Server.CreateObject("OWC11.Chartspace")

Set oChartConstants = oChart.Constants

Set oChart.DataSource = oRecordSet

oChart.Charts.Add

oChart.Charts(0).Type = oChart.Constants.chChartTypeColumnClustered

oChart.Charts(0).SeriesCollection.Add

oChart.Charts(0).SeriesCollection(0).SetData
oChartConstants.chDimCategories, 0, "Agent"

oChart.Charts(0).SeriesCollection(0).SetData
oChartConstants.chDimValues, 0, "Total"

oChart.ExportPicture szFileName, "gif", 800, 400

If i loop through the recordset and convert it to a couple of arrays
and use:
oChart.Charts(0).SeriesCollection(0).SetData
oChartConstants.chDimCategories, oChartConstants.chDataLiteral,
arrAgent

oChart.Charts(0).SeriesCollection(0).SetData
oChartConstants.chDimValues, oChartConstants.chDataLiteral, arrTotal
it works!

I believe i create the recordset correctly (i know its fussy about the
cursor):

szConStr = "Provider=OraOLEDB.Oracle;" &_

"Data Source=(XXXXXX);User Id=XXX;Password=XXX;PLSQLRSet=1;"

Set oDB = server.CreateObject("ADODB.Connection")

oDB.ConnectionString = szConStr

oDB.Open
Set oCmd = Server.CreateObject("ADODB.Command")

oCmd.ActiveConnection = oDB

oCmd.CommandType = adCmdStoredProc

oCmd.CommandText = "pkg.procedure"
oCmd.Parameters.Append oCmd.CreateParameter("P1", adVarChar,
adParamInput, szParameter,szParameter
Set oRS = CreateObject("ADODB.RecordSet")

oRS.CursorType = adOpenStatic

oRS.CursorLocation = adUseClient

Set oRS = oCmd.Execute

Any thoughts??? where have i gone wrong? i cant even find any usefull
documentation or sample code!
 
A

Alvin Bruney [ASP.NET MVP]

There's a particular syntax to follow to bind to a record set, have a google
for chart recordset.

--
Regards,
Alvin Bruney

Auther Plug
OWC Blackbook now on download at www.lulu.com/owc
 
R

r7dis8qh

Thanks for the response, it took me a while, but it's sorted!
....not that google really helped all that much, i bought a copy of
your book ;-)

all the examples i've seen bind the data to the chart, rather than the
chartspace (as you suggest in your 'rule of thumbs' table), as many
have experienced, using cspace.datasource and cspace.charts.add
togeather results in an extra blank table, so i'd been trying to bind
the data to cspace.charts(0) which works for arrays, but throws error
'80004005' when used with a record set

so it seems we have to bind the data to the chartspace and then the
'formatting' to cspace.chart(0), which seems a little counter-
intuitive to me...

but, working result is this:

Function Chart (oRecordSet)

Set oChartSpace = Server.CreateObject("OWC11.Chartspace")

Set c = oChartSpace.Constants

Set oChartSpace.DataSource = oRecordSet


oChartSpace.Charts(0).HasLegend = True

oChartSpace.Charts(0).Type = c.chChartTypeColumnClustered

oChartSpace.SetData c.chDimCategories, c.chDataBound, "Agent"

oChartSpace.SetData c.chDimValues, c.chDataBound, "Total"

Set oFso = Server.CreateObject("Scripting.FileSystemObject")

szFileName = Server.MapPath(".") & "\" & oFso.GetTempName()


oChartSpace.ExportPicture szFileName, "gif", 800, 400


Chart = ReadByteArray(szFileName)

oFSO.DeleteFile szFileName

End Function

now i just need to pretty it up...

PS. Great book Alvin, and a bargain!
 
A

Alvin Bruney [ASP.NET MVP]

Thanks for posting the code, it will help someone else i'm sure.

the blackbook has taken on a life of its own :)

--
Regards,
Alvin Bruney

Auther Plug
OWC Blackbook now on download at www.lulu.com/owc
 

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