Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 June 17th, 2003, 07:19 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Manipulating data in ASP

I have an issue with manipulating a data in ASP. I have to give the
final output as a %age of the records. My SQL query is something like
this:
1)
Select T.CustDealerID, count(*) As RecordCount,
D.DealerCompanyDesignator, D.DealerRegionID FROM
NACCO_WEB.dbo._tmpSampleCustomerDealerReviewFromWe b_Q1 T,
NACCO_WEB.dbo.lkuDealer D Where T.CustDealerID = D.DealerID AND
(T.IPContactFullNm is not NULL or T.PSContactFullNm is not NULL)
Group by T.CustDealerID, D.DealerCompanyDesignator, D.DealerRegionID
ORDER BY T.CustDealerID, D.DealerCompanyDesignator, D.DealerRegionID

When I display my records I have to display the record count as the
percentile of this query:
2)
Select count(T.CustDealerID) As RecordCount,
D.DealerCompanyDesignator, D.DealerRegionID FROM
NACCO_WEB.dbo._tmpSampleCustomerDealerReviewFromWe b_Q1 T,
NACCO_WEB.dbo.lkuDealer D WHERE T.CustDealerID = D.DealerID Group by
D.DealerCompanyDesignator, D.DealerRegionID ORDER by
D.DealerCompanyDesignator, D.DealerRegionID

Essentially I am trying to get the record count as
(1 query's count(*) As RecordCount / 2 query's count(*) As
RecordCount) * 100

My ASP code is as follows:
<% Option Explicit%>
<% Response.ContentType = "application/vnd.ms-excel" %>

<HTML>
<HEAD>
<TITLE>Percent Of Records with Contact Name by Region/Brand</TITLE>
</HEAD>
<BODY>
<BODY>
<TABLE BORDER=0>
<TR>
<TD align=center colspan=8><H2>Percentile of Records With Contact
Name by Region/Dealer Access Tracking Report</H2></TD>
</TR>
<TR>
<TD align=left colspan=8><% Response.Write "Created on " &
FormatDateTime(Date, 1) %></TD>
</TR>
</TABLE>
<TABLE BORDER=0>
<TR><TD align=left colspan=8>&nbsp;</TD></TR>
</TABLE>
<TABLE BORDER="1">
<TR>
<TD align=center><STRONG>Customer DealerID</STRONG></A></TD>
<TD align=center><STRONG>Dealer Region ID</STRONG></A></TD>
<TD align=center><STRONG>Dealer Company</STRONG></A></TD>
<TD align=center><STRONG>Counts</STRONG></A></TD>
<TD align=center><STRONG>Percentile(%)</STRONG></A></TD>
</TR>
<%
Dim objRs: Set objRs = Server.CreateObject("ADODB.Recordset")
Dim objConn: Set objConn = Server.CreateObject("ADODB.Connection")
Dim intCheckCounter
Dim intLnCnt
objConn.Open "Provider=SQLOLEDB.1;Initial Catalog=Web;Data Source=" &
SERVER_DB & ";UID=777;PWD=222"

With objRs
.Open "Select T.CustDealerID, count(*) As RecordCount,
D.DealerCompanyDesignator, D.DealerRegionID FROM
_tmpSampleCustomerDealerReviewFromWeb_Q1 T, dbo.lkuDealer D Where
T.CustDealerID = D.DealerID AND (T.IPContactFullNm is not NULL or
T.PSContactFullNm is not NULL) Group by T.CustDealerID,
D.DealerCompanyDesignator, D.DealerRegionID ORDER BY T.CustDealerID,
D.DealerCompanyDesignator, D.DealerRegionID", objConn
'' This is the total number of records that the dealer has.
'.Open "Select T.CustDealerID, count(T.CustDealerID) As RecordCount1,
D.DealerCompanyDesignator, D.DealerRegionID FROM
dbo._tmpSampleCustomerDealerReviewFromWeb_Q1 T, dbo.lkuDealer D WHERE
T.CustDealerID = D.DealerID Group by T.CustDealerID,
D.DealerCompanyDesignator, D.DealerRegionID ORDER by T.CustDealerID,
D.DealerCompanyDesignator, D.DealerRegionID", objConn
If Not .EOF Then .MoveFirst
Do While Not .EOF
Response.Write "<TD align=left>" & objRs.Fields("CustDealerID")
& "</TD>"
Response.Write "<TD align=left>" & objRs.Fields("DealerRegionID")
& "</TD>"
Response.Write "<TD align=left>" & objRs.Fields
("DealerCompanyDesignator") & "</TD>"
Response.Write "<TD align=left>" & objRs.Fields("RecordCount")
& "</TD>"
Response.Write "<TD align=left>" & objRs.Fields("Percentile")
& "</TD>"
Response.Write "</TR>"
SET intlnCnt = RecordCount
.MoveNext
Loop

.Close
End With
Set objRs = Nothing
Set objConn = Nothing
%>

</TABLE>
</BODY>
</HTML>


I tried using the logic of having both the SQL query executed from
the same place but I got an error as ADODB.Recordset EOT and BOF----.
I am not very sure where I am missing:
I know the logic has to be somewhere here:
With objRs
.Open "Select T.CustDealerID, count(*) As RecordCount,
D.DealerCompanyDesignator, D.DealerRegionID FROM
_tmpSampleCustomerDealerReviewFromWeb_Q1 T, dbo.lkuDealer D Where
T.CustDealerID = D.DealerID AND (T.IPContactFullNm is not NULL or
T.PSContactFullNm is not NULL) Group by T.CustDealerID,
D.DealerCompanyDesignator, D.DealerRegionID ORDER BY T.CustDealerID,
D.DealerCompanyDesignator, D.DealerRegionID", objConn
'' This is the total number of records that the dealer has.
'.Open "Select T.CustDealerID, count(T.CustDealerID) As RecordCount1,
D.DealerCompanyDesignator, D.DealerRegionID FROM
dbo._tmpSampleCustomerDealerReviewFromWeb_Q1 T, dbo.lkuDealer D WHERE
T.CustDealerID = D.DealerID Group by T.CustDealerID,
D.DealerCompanyDesignator, D.DealerRegionID ORDER by T.CustDealerID,
D.DealerCompanyDesignator, D.DealerRegionID", objConn
If Not .EOF Then .MoveFirst
Do While Not .EOF
Response.Write "<TD align=left>" & objRs.Fields("CustDealerID")
& "</TD>"
Response.Write "<TD align=left>" & objRs.Fields("DealerRegionID")
& "</TD>"
Response.Write "<TD align=left>" & objRs.Fields
("DealerCompanyDesignator") & "</TD>"
Response.Write "<TD align=left>" & objRs.Fields("RecordCount")
& "</TD>"
Response.Write "<TD align=left>" & objRs.Fields("Percentile")
& "</TD>"
Response.Write "</TR>"
SET intlnCnt = RecordCount
.MoveNext
Loop

.Close
End With

Any thoughts - pointers?
Thanks
Sri





Similar Threads
Thread Thread Starter Forum Replies Last Post
Manipulating Data with Expressions baaul Reporting Services 2 June 22nd, 2006 10:14 AM
Manipulating Data Problem - - - - Please Help! sendoh11 ASP.NET 1.0 and 1.1 Professional 1 June 29th, 2005 02:40 AM
manipulating data in mysql using php - countries phpnukes BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 January 24th, 2005 01:35 AM
Manipulating the data in db dungey PHP Databases 4 January 6th, 2005 11:31 AM
manipulating data in DAO jimmy Access VBA 2 November 19th, 2003 10:55 AM





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