Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2007, 08:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default sql query in asp graph

How can move / transfer sql query output to asp Array ?

we want that sql query output move to asp Array to display the
employee progress in graph.

query is

DECLARE @totalVideos int SET @totalVideos = (SELECT COUNT(*)
FROM Training_Module) SELECT t2.Name,
COUNT(t1.emp_id)*100/44 as ViewPercentage
FROM Module_View t1 JOIN Employee t2 ON t1.emp_id = t2.emp_id
JOIN Department t3 ON t2.Department_Code = t3.Department_Code
JOIN Position t4 ON t2.Position_Code = t4.Position_Code
GROUP BY t2.emp_id, t1.emp_id,t2.Name

above query retrieve following percentage of employee like this.

Employee Name.....ViewPercentage
Khan 20
Ibrahim 25
Peterr 35
....
..

above query result move to following asp Array
following is the fix value use in Array,
inplace of following fix value sql query result move to Array how ?

<%
...
........

ShowChart Array(6, 10, 12, 18, 23, 26, 27, 28, 30, 34, 37, 45, 55), Array("P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11", "P12", "P13"), "Safety Make It Personal", "Employee ", "Progress"


Response.Write "<BR>" & vbCrLf
Response.Write "<BR>" & vbCrLf
Response.Write "<BR>" & vbCrLf

Dim I
Dim aTemp(49)

Randomize
For I = 0 to 49
    aTemp(I) = Int((50 + 1) * Rnd)
Next 'I
%>


regards
Mateen
 
Old July 8th, 2007, 07:13 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;How can move / transfer sql query output to asp Array ?
use the getRows() method:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=161

Wind is your friend
Matt
 
Old August 4th, 2007, 04:28 AM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mat41
 ;;;How can move / transfer sql query output to asp Array ?
use the getRows() method:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=161

Wind is your friend
Matt
Hi everyone,

I checked the examples given by Matt but i couldnt succeded.Below is my codes, i try to transfer sql querry results to array(degerler).But unable to do this.Could you help me how can i do that.

<%
Dim Gemiler, Partiler, Degerler
Gemiler=Array("Besiktas", "Bosphorus", "Dardanelles", "Greenland", "Scotland", "Tena")
Partiler=Array("MOC", "MOU", "Class", "Company", "Internal")
Veri_yolu = Server.MapPath("db/vessels.mdb")
Bcumle = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Veri_yolu
Set bag = Server.Createobject("ADODB.Connection")
bag.Open (Bcumle)
for i=0 to Ubound(gemiler)
SQL = "SELECT COUNT(*) as TOPLAM FROM tblmain where Vname='"&gemiler(i)&"' and iparty='MOC';"
Set rs = bag.Execute(SQL)
Total =rs("Toplam")
response.write total
response.write "<BR>"
degerler = rs.GetRows(6,0)
    for j = 0 to ubound(degerler)
    response.write "second column : " & degerler(0,j) & "<br>"
    next
next

rs.close
set rs = Nothing
bag.close
set bag = Nothing
%>

 
Old August 5th, 2007, 07:46 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Did you look at the link I posted? if you had you would realize this can not be done:
degerler = rs.GetRows(6,0)

The code is there for you, have a look at the link

Wind is your friend
Matt
 
Old August 6th, 2007, 12:48 AM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes i read and applied all the lines in yr link. But unable to do what i want to do ;)

 
Old August 6th, 2007, 12:53 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

You need to get a little more detail in your post. Whats your browser behaviour, specifically your error? I assume its on this line:

degerler = rs.GetRows(6,0)

Wind is your friend
Matt
 
Old August 6th, 2007, 01:14 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Since I am going home soon here is a very simplistic example. It assumes you have connected to the DB

DIM groupArray,groupCount,getGroups,count
count = 0

sql = "SELECT id,accronym,shortName FROM groups WHERE inactive=0 and id > 0 ORDER BY fOrder;"
set getGroups = conn.execute(sql)

IF NOT getGroups.EOF THEN
groupArray = getGroups.GetRows
groupCount = UBound(groupArray, 2)
getGroups.Close
Set getGroups = Nothing
END IF

NOTE: You can close your database connection here. A good practice if you dont require it

DO WHILE count <= groupCount
response.write groupArray(0,count) & " : I am the ID part of the SQL above<bR>"
response.write groupArray(1,count) & " : I am the accronym part of the SQL above<bR>"
response.write groupArray(2,count) & " : I am the shortName part of the SQL above<bR>"
count = count + 1
LOOP

set groupArray = nothing

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
asp and graph mateenmohd Classic ASP Basics 0 June 28th, 2007 07:38 AM
Sql Query Help - ASP cancer10 Classic ASP Databases 8 November 7th, 2006 03:19 PM
Graph in asp mateenmohd Classic ASP Basics 0 June 2nd, 2006 11:05 AM
Any Expert know using Graph in ASP itHighway Classic ASP Basics 2 March 25th, 2005 05:53 PM
Graph Based Query maha Access 0 October 2nd, 2003 03:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.