473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Server-side DB & client-side chart

I have connected to SQL Server database (server-side vbscript) and read some
data from the tables. This works correctly. I now have the data in an array
(server-side).

I have to draw a line-chart based on that data, for which purpose I need to
create client-side component (this works also perfectly).

PROBLEM: I cannot use the server-side array for drawing the chart.

Here's the code shortly:

<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>Graph</title>
</head>
<%
Session.Timeout = 10
Response.Expires = -1000
Dim objConn, objRS, strQuery
Dim objRS2, strQuery2
Dim strConnection
Dim dataArray(999)

Set objConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=LocalServer;Database=ASPTest;UID=sa;PWD=; "
objConn.Open strConnection

'count number of records
strQuery = "SELECT Count(*) AS recCount FROM tblCurrent"
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strQuery, objConn, 3, 3

Response.Write(objRS("recCount") & "<br><br>")

'read the firstname and the lastname
strQuery2 = "SELECT * FROM tblCurrent"
set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open strQuery2, objConn, 3, 3

for i = 0 to (objRS("recCount")-1)
dataArray(i) = objRS2("fCurrent")
Response.Write (dataArray(i) & "<br>")
objRS2.movenext
next

objConn.Close
set objConn = nothing

%>
<script language="vbscript">
function updateData()
TChart1.AddSeries(asFastLine)
TChart1.Series(0).Clear
TChart1.Zoom.Enable = true
TChart1.Legend.CheckBoxes = true

with TChart1
.Zoom.Animated = true
.Zoom.AnimatedSteps = 5
end with

TChart1.Series(0).AddArray 9, array1
end function
</script>
<body>

<input type="button" value="Example" name="btnChart" onClick="updateData()"
style="position:absolute;top:550px;left:10px">

<OBJECT classid="clsid:536600D3-70FE-4C50-92FB-640F6BFC49AD"
codebase="TeeChart6.ocx#version=6,0,0,0"
id=TChart1
TYPE="application/x-oleobject"
width=500
height=400
align=center
hspace=0
vspace=0
style="position:absolute;top:100px;left:100px">
</OBJECT>

</body>
</html>

Anyone know, how to use the server-side array in my client-side code for
drawing the chart?

TIA

Mike
Jul 19 '05 #1
3 2646
Idea.

Write out Javascript that 'creates' an array on the client side to then pass
to the component.

eg.

Response.Write "<SCRIPT language=Javascript>"
Response.Write " var parrArray = new Array();"
Response.Write " parrArray = '[12,13,14,15]';"
Response.Write "</SCRIPT>

Of course the 12...15 would be output probably by a loop of some sort.

Anyway, once you have the array at the client end then pass that to the
client-side component.

Hope this helps.

Chris.
"Mick Turner" <c_******@hotmail.com> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...
I have connected to SQL Server database (server-side vbscript) and read some
data from the tables. This works correctly. I now have the data in an array
(server-side).

I have to draw a line-chart based on that data, for which purpose I need to
create client-side component (this works also perfectly).

PROBLEM: I cannot use the server-side array for drawing the chart.

Here's the code shortly:

<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>Graph</title>
</head>
<%
Session.Timeout = 10
Response.Expires = -1000
Dim objConn, objRS, strQuery
Dim objRS2, strQuery2
Dim strConnection
Dim dataArray(999)

Set objConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=LocalServer;Database=ASPTest;UID=sa;PWD=; "
objConn.Open strConnection

'count number of records
strQuery = "SELECT Count(*) AS recCount FROM tblCurrent"
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strQuery, objConn, 3, 3

Response.Write(objRS("recCount") & "<br><br>")

'read the firstname and the lastname
strQuery2 = "SELECT * FROM tblCurrent"
set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open strQuery2, objConn, 3, 3

for i = 0 to (objRS("recCount")-1)
dataArray(i) = objRS2("fCurrent")
Response.Write (dataArray(i) & "<br>")
objRS2.movenext
next

objConn.Close
set objConn = nothing

%>
<script language="vbscript">
function updateData()
TChart1.AddSeries(asFastLine)
TChart1.Series(0).Clear
TChart1.Zoom.Enable = true
TChart1.Legend.CheckBoxes = true

with TChart1
.Zoom.Animated = true
.Zoom.AnimatedSteps = 5
end with

TChart1.Series(0).AddArray 9, array1
end function
</script>
<body>

<input type="button" value="Example" name="btnChart" onClick="updateData()"
style="position:absolute;top:550px;left:10px">

<OBJECT classid="clsid:536600D3-70FE-4C50-92FB-640F6BFC49AD"
codebase="TeeChart6.ocx#version=6,0,0,0"
id=TChart1
TYPE="application/x-oleobject"
width=500
height=400
align=center
hspace=0
vspace=0
style="position:absolute;top:100px;left:100px">
</OBJECT>

</body>
</html>

Anyone know, how to use the server-side array in my client-side code for
drawing the chart?

TIA

Mike

Jul 19 '05 #2

I use this technique alot ... 'cept I get lazy with my response writes
.... just throw the array into a delimited string, and write the string
into the javascript

Response.Write "var arrString = " & yourDelimitedString
then just include the split command to get this into your array

Brynn
www.coolpier.com


On Thu, 29 Jan 2004 14:42:15 -0000, "Chris Barber"
<ch***@blue-canoe.co.uk.NOSPAM> wrote:
Idea.

Write out Javascript that 'creates' an array on the client side to then pass
to the component.

eg.

Response.Write "<SCRIPT language=Javascript>"
Response.Write " var parrArray = new Array();"
Response.Write " parrArray = '[12,13,14,15]';"
Response.Write "</SCRIPT>

Of course the 12...15 would be output probably by a loop of some sort.

Anyway, once you have the array at the client end then pass that to the
client-side component.

Hope this helps.

Chris.
"Mick Turner" <c_******@hotmail.com> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...
I have connected to SQL Server database (server-side vbscript) and read some
data from the tables. This works correctly. I now have the data in an array
(server-side).

I have to draw a line-chart based on that data, for which purpose I need to
create client-side component (this works also perfectly).

PROBLEM: I cannot use the server-side array for drawing the chart.

Here's the code shortly:

<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>Graph</title>
</head>
<%
Session.Timeout = 10
Response.Expires = -1000
Dim objConn, objRS, strQuery
Dim objRS2, strQuery2
Dim strConnection
Dim dataArray(999)

Set objConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=LocalServer;Database=ASPTest;UID=sa;PWD=; "
objConn.Open strConnection

'count number of records
strQuery = "SELECT Count(*) AS recCount FROM tblCurrent"
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strQuery, objConn, 3, 3

Response.Write(objRS("recCount") & "<br><br>")

'read the firstname and the lastname
strQuery2 = "SELECT * FROM tblCurrent"
set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open strQuery2, objConn, 3, 3

for i = 0 to (objRS("recCount")-1)
dataArray(i) = objRS2("fCurrent")
Response.Write (dataArray(i) & "<br>")
objRS2.movenext
next

objConn.Close
set objConn = nothing

%>
<script language="vbscript">
function updateData()
TChart1.AddSeries(asFastLine)
TChart1.Series(0).Clear
TChart1.Zoom.Enable = true
TChart1.Legend.CheckBoxes = true

with TChart1
.Zoom.Animated = true
.Zoom.AnimatedSteps = 5
end with

TChart1.Series(0).AddArray 9, array1
end function
</script>
<body>

<input type="button" value="Example" name="btnChart" onClick="updateData()"
style="position:absolute;top:550px;left:10px">

<OBJECT classid="clsid:536600D3-70FE-4C50-92FB-640F6BFC49AD"
codebase="TeeChart6.ocx#version=6,0,0,0"
id=TChart1
TYPE="application/x-oleobject"
width=500
height=400
align=center
hspace=0
vspace=0
style="position:absolute;top:100px;left:100px">
</OBJECT>

</body>
</html>

Anyone know, how to use the server-side array in my client-side code for
drawing the chart?

TIA

Mike


Brynn
www.coolpier.com

I participate in the group to help give examples of code.
I do not guarantee the effects of any code posted.
Test all code before use!
Jul 19 '05 #3
"Mick Turner" <c_******@hotmail.com> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...
I have connected to SQL Server database (server-side vbscript) and read some data from the tables. This works correctly. I now have the data in an array (server-side).

I have to draw a line-chart based on that data, for which purpose I need to create client-side component (this works also perfectly).

PROBLEM: I cannot use the server-side array for drawing the chart.

Here's the code shortly:

<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>Graph</title>
</head>
<%
Session.Timeout = 10
Response.Expires = -1000
Dim objConn, objRS, strQuery
Dim objRS2, strQuery2
Dim strConnection
Dim dataArray(999)

Set objConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=LocalServer;Database=ASPTest;UID=sa;PWD=; "
objConn.Open strConnection

'count number of records
strQuery = "SELECT Count(*) AS recCount FROM tblCurrent"
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strQuery, objConn, 3, 3

Response.Write(objRS("recCount") & "<br><br>")

'read the firstname and the lastname
strQuery2 = "SELECT * FROM tblCurrent"
set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open strQuery2, objConn, 3, 3

for i = 0 to (objRS("recCount")-1)
dataArray(i) = objRS2("fCurrent")
Response.Write (dataArray(i) & "<br>")
objRS2.movenext
next

objConn.Close
set objConn = nothing

%>
<script language="vbscript">
function updateData()
TChart1.AddSeries(asFastLine)
TChart1.Series(0).Clear
TChart1.Zoom.Enable = true
TChart1.Legend.CheckBoxes = true

with TChart1
.Zoom.Animated = true
.Zoom.AnimatedSteps = 5
end with

TChart1.Series(0).AddArray 9, array1
end function
</script>
<body>

<input type="button" value="Example" name="btnChart" onClick="updateData()" style="position:absolute;top:550px;left:10px">

<OBJECT classid="clsid:536600D3-70FE-4C50-92FB-640F6BFC49AD"
codebase="TeeChart6.ocx#version=6,0,0,0"
id=TChart1
TYPE="application/x-oleobject"
width=500
height=400
align=center
hspace=0
vspace=0
style="position:absolute;top:100px;left:100px">
</OBJECT>

</body>
</html>

Anyone know, how to use the server-side array in my client-side code for drawing the chart?


<%@LANGUAGE="VBSCRIPT"%>
<%
Dim cn,rs,arr,str
Set cn = CreateObject("ADODB.Connection")
cn.Open "<Your DSN-Less OLEDB Connection String>"
Set rs = cn.Execute "SELECT fCurrent FROM tblCurrent"
If Not rs.EOF Then arr = rs.GetRows()
rs.Close : Set rs = Nothing
cn.Close : Set cn = Nothing
If IsArray(arr) Then str = Join(arr,",")
%>
<html>
<head>
<title>Graph</title>
<script language="vbscript">
function updateData()
Dim array1
array1 = Array(<%=str%>)
TChart1.AddSeries(asFastLine)
TChart1.Series(0).Clear
TChart1.Zoom.Enable = true
TChart1.Legend.CheckBoxes = true
with TChart1
.Zoom.Animated = true
.Zoom.AnimatedSteps = 5
end with
TChart1.Series(0).AddArray 9, array1
end function
</script>
</head>
<body>
<input type="button" value="Example" name="btnChart"
onClick="updateData()"
style="position:absolute;top:550px;left:10px">
<OBJECT classid="clsid:536600D3-70FE-4C50-92FB-640F6BFC49AD"
codebase="TeeChart6.ocx#version=6,0,0,0"
id=TChart1
TYPE="application/x-oleobject"
width=500
height=400
align=center
hspace=0
vspace=0
style="position:absolute;top:100px;left:100px">
</OBJECT>
</body>
</html>

Notes:
1. When referencing a database, please provide DDL and sample data.
Here's an article:
http://aspfaq.com/5006

2. Please consider using a DSN-Less OLEDB connection string. Here's an
article:
http://aspfaq.com/2126

3. Please try to avoid using "SELECT *". Here's an article:
http://aspfaq.com/2096

HTH
-Chris Hohmann

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
0
by: Philip Trim | last post by:
General Brief: 3 SQL Servers as MS SQL Server 2000 Standard Edition with Service Pack 3 All using FTP for snapshots All Servers are both Publishers and Distributors. Server A has the correct...
5
by: Grim Reaper | last post by:
My work let me put SQL Server 7.0 Enterprise Edition on my laptop. I have never setup a server from the beginning, so I am a little new at creating server groups. Alright, I am trying to create...
2
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an...
22
by: EP | last post by:
When running my asp.net hosting service (asp.net without IIS), on server 2003 with IIS not installed, I get the following when trying to process a request. "System.DllNotFoundException: Unable to...
4
by: coosa | last post by:
Hi, I was installing SQL Server on my machine and during installation my PC freezed. It happens frequently on my machine. So i tried after restarting to install it again and since then i always...
1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
10
by: sara | last post by:
Hi All, I was able to connect to MS SQL Server 2005 on my computer but after a while I can not. When I want to connect to it using MS SQL Server Management Studio I got this error: An error...
1
by: manish deshpande | last post by:
Hi, When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command: rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown: ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.