insert a chart on a page using data from my database


F

faamugol

Hello

I work in ASP with SQL server.I'd like to insert a chart on a pag
which I like to use data from my database (via a system DSN).

Question: how do I get that chart to link to a data source?

here is the code I use, but I dont get any error

<!-- #includ
file="conf/sqlserver.asp" --

<

' constante
dim myCon
DBName = "NUTS_MEETDB2"
sqlserverlocation = sqlserve
sqldbname = DBNAM
'call RunChart(
'Response.BinaryWrite(RunChart
'Example uses TeeChart's example System ODBC datasource

'Send output to browser. 1st time in call CreatePag
'then call RunChart method to build Chart content
if Request.QueryString("CreateChart")=1 The
Response.BinaryWrite(RunChart
else
CreatePag
end if
'call RunChar
Function RunChart(

dim im
dim Char
dim MyVa

'Create Char
Set Chart = CreateObject("TeeChart.TChart"

'Setup Serie
Chart.AddSeries(scBar
Chart.Series(0).Marks.Visible=Fals

'Chart.Series(0).asBar.BarStyle=bsPyrami

'Chart appearanc
Chart.Legend.Visible=Fals
Chart.Axis.Bottom.Labels.Angle=9
Chart.Height=40
Chart.Width=50
Chart.Panel.Gradient.Visible=Tru
Chart.Header.Text(0)="TeeChart ADO example
Chart.Header.Font.Bold=Tru
Chart.Axis.Bottom.Title.Caption="Product name
Chart.Axis.Bottom.Title.Font.Bold=True
Chart.Axis.Left.Title.Font.Bold=True

'Create a random condition to vary the outpu
Randomiz
MyVar = (40000)+CInt(rnd*20000
'Chart.Axis.Left.Title.Caption="Order Item Totals >
& MyVa

'Connect to databas
ErrString = "
Err.Clea

call OpenDatabase(

SQLST = "Select tijdstip, datameeting from Meeting

Set RSt = Server.CreateObject("ADODB.RecordSet")
Set myConRst = myConn.Execute(SQLST, , 1
RSt.Open SQLST, myConn,
On error resume nex

if err the
Response.Write err.Descriptio
end if

'Connect Series to Recordse
if RSt.RecordCount > 0 then
Chart.Series(0).Datasource = RS
Chart.Series(0).LabelsSource="time
Chart.Series(0).YValues.ValueSource="Data
els
Chart.Series(0).Fillsamplevalues(10
Chart.Header.Text(0)="ADO database returned no values
using random data
end i

'Cleanup and set Chart to send to browser
call CloseDatabase(
img=Chart.Export.asPNG.SaveToStrea
Set Chart=nothin
RunChart=im

End functio

Function CreatePag
Response.Write("<html>"
chr(13)
Response.Write("<HEAD><title>TeeChart Pro A
Control ADO with ASP example</title>"
chr(13)
Response.Write("<LINK REL=STYLESHEE
TYPE=""text/css"
HREF=""Style.css""></HEAD><BODY>
& chr(13)
Response.Write("<im
src=""TeeChart5.png"">"
chr(13)
Response.Write("<br><br>"
chr(13)
Response.Write("<
href=""ASPHome.htm"">Back to Content
page</a>" & chr(13)
Response.Write("<hr>" & chr(13)
Response.Write("<img id=Img
src=""ADOTeeChart5.asp?CreateChart=1"">
& chr(13)
Response.Write("<p>Please note that server Datsource
should be System DSNs not User DSNs.</p>"
chr(13)
Response.Write("<HR>Copyright © 2002 Steema Softwar
SL</BODY></HTML>" & chr(13)
Response.Write("</body>"
chr(13)
Response.Write("</html>"
chr(13)
End Functio

function OpenDatabase(

Application.loc

sConnection = "DRIVER={SQL SERVER};Server="
sqlserverlocation & ";Database=" & sqldbname
";UID=AiSE_RW;PWD=3333
Set myConn = Server.CreateObject("ADODB.Connection"

myConn.open sConnectio

end functio

function CloseDatabase(

On error resume nex
RSt.Close
myConn.Close
Set RSt = nothin
set myConn = nothin
application.unlock

end functio

%
Can any one help me or to give me a code that should work


I'm new in ASP
Thanks
Faamugo
 
Ad

Advertisements


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