Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Display Compute Value


Message #1 by devonlivolsi@h... on Mon, 3 Feb 2003 21:17:20
How do I display the "compute" value in my asp page?

Example code:
<%@ Language = "vbscript" %>
<% Option explicit %>
<%
dim connection
dim cConn
dim cRS
dim cSQL
set connection = Server.CreateObject("ADODB.Connection")
cConn = "Driver={SQL Server};Server=DEV;uid=sa;pwd=as;database=Test1"

	cSQL = " select field1, field2, field3 from Table "
	cSQL = cSQL + " compute count(field1)"

connection.open cConn
set cRS = connection.Execute(cSQL)

do while not cRS.EOF
response.write cRS.Fields("field1") & "&nbsp&nbsp&nbsp&nbsp"
response.write cRS.Fields("field2") & "&nbsp&nbsp&nbsp&nbsp"
response.write cRS.Fields("field3") & "&nbsp&nbsp&nbsp&nbsp"
response.write "<br>"	
cRS.MoveNext

loop
%>
Message #2 by devonlivolsi@h... on Mon, 3 Feb 2003 21:32:57
I used a work-around by first displaying the query results for select count
(*) as [Count], field1 from Table
group by field1

But is there a way to use a compute clause and have it display in asp 
similar to the way it displays in SQL 7 query analyzer?

> How do I display the "compute" value in my asp page?

> Example code:
<> %@ Language = "vbscript" %>
<> % Option explicit %>
<> %
d> im connection
d> im cConn
d> im cRS
d> im cSQL
s> et connection = Server.CreateObject("ADODB.Connection")
c> Conn = "Driver={SQL Server};Server=DEV;uid=sa;pwd=as;database=Test1"

> 	cSQL = " select field1, field2, field3 from Table "
	> cSQL = cSQL + " compute count(field1)"

> connection.open cConn
s> et cRS = connection.Execute(cSQL)

> do while not cRS.EOF
r> esponse.write cRS.Fields("field1") & "&nbsp&nbsp&nbsp&nbsp"
r> esponse.write cRS.Fields("field2") & "&nbsp&nbsp&nbsp&nbsp"
r> esponse.write cRS.Fields("field3") & "&nbsp&nbsp&nbsp&nbsp"
r> esponse.write "<br>"	
c> RS.MoveNext

> loop
%
Message #3 by devonlivolsi@h... on Mon, 3 Feb 2003 21:37:45
Sorry for the bother I found a post that may help 
(http://p2p.wrox.com/archive/asp_web_howto/2001-02/7.asp). Please ignor 
this one.

> How do I display the "compute" value in my asp page?

> Example code:
<> %@ Language = "vbscript" %>
<> % Option explicit %>
<> %
d> im connection
d> im cConn
d> im cRS
d> im cSQL
s> et connection = Server.CreateObject("ADODB.Connection")
c> Conn = "Driver={SQL Server};Server=DEV;uid=sa;pwd=as;database=Test1"

> 	cSQL = " select field1, field2, field3 from Table "
	> cSQL = cSQL + " compute count(field1)"

> connection.open cConn
s> et cRS = connection.Execute(cSQL)

> do while not cRS.EOF
r> esponse.write cRS.Fields("field1") & "&nbsp&nbsp&nbsp&nbsp"
r> esponse.write cRS.Fields("field2") & "&nbsp&nbsp&nbsp&nbsp"
r> esponse.write cRS.Fields("field3") & "&nbsp&nbsp&nbsp&nbsp"
r> esponse.write "<br>"	
c> RS.MoveNext

> loop
%

  Return to Index