| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||||||||
|
|||||||||||
|
Classic ASP/VBScript - Getting away from Recordsets, use GetRows()
I won't go into detail on why using GetRows()'s two dimensional arrays is so much better, but what I will say is that using GetRows() is FAR, FAR, FAR more efficient than iterating through a recordset. For more information, check out this link.
Anyhow, instead of the following traditional code: ASP Code:
This code will produce the same output, but at much faster, more efficient speeds: ASP Code:
To shorten code, you could create the following function: ASP Code:
__________________
www.xoise.com - www.ourfreegames.com - www.playtouchgames.com - www.randomtools.net - www.xenocide-rpg.com |
|
#2
|
|||
|
|||
|
hi
i tried using get rows as per your thread....its working but am not able to write in a table the content of the array as am not that intelligent guy in asp....beginner only so.....can any body find what is the error?? it displays one header with value and not the circle name i intended to display...and one cell data. thats all nothing else...actually i need to display the first row as header ...values of (0,0),(0,1)...and so on and the values in row 2 of the table (1,0),(1,1)...and so on Code:
<!--#include virtual="\envision\include\dbconnection.inc"-->
<!--#include virtual="\envision\include\settings.asp"-->
<!--#include virtual="\envision\activeusers.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="Description" content="Information architecture, Web Design, Web Standards." />
<meta name="Keywords" content="your, keywords" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Distribution" content="Global" />
<meta name="Author" content="Aemunathan - aemunathan.r@gmail.com" />
<meta name="Robots" content="index,follow" />
<link rel="stylesheet" href="/envision/css/Envision.css" type="text/css" />
<link rel="stylesheet" href="/envision/css/menuh.css" type="text/css"/>
<style type="text/css" media="screen">
#menuh{float:none;}
body{behavior:url(/envision/css/csshover.htc); font: 70%/1.5em Verdana, Tahoma, arial, sans-serif;}
#menuh ul li{float:left; width: 100%;}
#menuh a{height:1%;font:bold 0.9em/1.4em arial, sans-serif;}
</style>
<script language="javascript" type="text/javascript" src="/envision/js/datetimepicker.js">
</script>
<title>Consolidated PFS report...</title>
</head>
<%
If Session("userGood") = False or IsNull(Session("userGood")) = True then
Response.Redirect"/envision/default.asp"
End If
strUserName = Replace(Session("userName"), "'", "''")
userID = Clng(Session("userID"))
userAdmin = Replace(Session("userAdmin"), "'", "''")
Session("userID") = userID
%>
<body>
<!--#include virtual="\envision\include\logo2menu.inc"-->
<!--#include virtual="\envision\include\sidebar.inc"-->
<!-- main starts here -->
<br><br>
<div id="main">
<form name="chat_rep" action="ConsolChatRep.asp" method="post">
<BR><br><BR><p align ="center">
<b>No of MSISDNs registered for Chatting service between</b> </p>
<table class="noborder" align="center">
<tr><td>
Start Date   </td>
<td><input id="sd" type="text" name="Sdate" size="25" readonly>
<a href="javascript:NewCal('sd','ddmmmyyyy')">
<img class="nopadding" src="/envision/images/cal.gif" width="18" height="18" alt="Pick a date"></a>
</td>
</tr><tr><td>
End Date   </td>
<td><input id="ed" type="text" name="Edate" size="25" readonly>
<a href="javascript:NewCal('ed','ddmmmyyyy')">
<img class="nopadding" src="/envision/images/cal.gif" width="18" height="18" border="0" alt="Pick a date"></a>
</td></tr>
</table>
                                                      
<input type ="submit" value ="Submit">
   
<input type ="reset" value="Reset">
</form>
<%
dim conn
dim sdate
dim edate
sdate =Request.Form("Sdate")
edate =Request.Form("Edate")
if sdate<>"" then
Set conn = Server.Createobject("ADODB.Connection")
conn.connectionstring = "Provider=OraOLEDB.Oracle;Data Source= xxxx;User Id=xx;Password=xx;"
conn.open
set objRS = Server.CreateObject("ADODB.recordset")
Function GetRSArray(strSQL)
Set objRS = Conn.Execute(strSQL)
If Not objRS.EOF Then
arrRS = objRS.GetRows()
Set objRS = Nothing
GetRSArray = arrRS
End If
End Function
arrRS = GetRSArray("SELECT (SELECT COUNT(*) FROM lbsservice.bsnl_dating_users WHERE TRUNC(register_date) BETWEEN '" & sdate & "'AND '" & edate & "' AND (msisdn LIKE '919447%' OR msisdn LIKE '919446%' OR msisdn LIKE '919495%' OR msisdn LIKE '919496%')) AS KERALA, (SELECT COUNT(*) FROM lbsservice.bsnl_dating_users WHERE TRUNC(register_date) BETWEEN '" & sdate & "' AND '" & edate & "' AND (msisdn LIKE '919444%' OR msisdn LIKE '919445%')) AS CHENNAI, (SELECT COUNT(*) FROM lbsservice.bsnl_dating_users WHERE TRUNC(register_date) BETWEEN '" & sdate & "'AND '" & edate & "' AND (msisdn LIKE '919443%' OR msisdn LIKE '919442%' OR msisdn LIKE '919486%' OR msisdn LIKE '919487%')) AS TAMIL_NADU, (SELECT COUNT(*) FROM lbsservice.bsnl_dating_users WHERE TRUNC(register_date) BETWEEN '" & sdate & "'AND '" &edate& "' AND (msisdn LIKE '919441%' OR msisdn LIKE '919490%' OR msisdn LIKE '919491%' OR msisdn LIKE '919440%') ) AS ANDHRA_PRADESH, (SELECT COUNT(*) FROM lbsservice.bsnl_dating_users WHERE TRUNC(register_date) BETWEEN '" & sdate & "'AND '" & edate & "' AND (msisdn LIKE '919449%' OR msisdn LIKE '919448%' OR msisdn LIKE '919480%' OR msisdn LIKE '919481%')) AS KARNATAKA FROM lbsservice.bsnl_dating_users WHERE ROWNUM=1")
If IsArray(arrRS) Then
For i = LBound(arrRS, 2) To UBound(arrRS, 2)
CIRCLE = arrRS(0, i)
COUNT = arrRS(1, i)
Response.Write "<table border=1>"
Response.Write "<tr>"
Response.Write("<th align='left' bgcolor='#bfd4bf'>" & CIRCLE & "</th>")
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>" & COUNT & "</td>"
Response.Write "</tr>"
Next
Erase arrRS
End If
conn.Close
Set conn = nothing
End If
%>
</div> <!-- main ends here -->
</div> <!-- content-wrap ends here -->
<!--#include virtual="\envision\include\footer.inc" -->
Aemunathan |
|
#3
|
||||
|
||||
|
Sorry for the late reply.
Are you sure your query is returning results correctly? Make sure you test that in Access/SQL Server/phpMyAdmin first. |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Classic ASP/VBScript - Getting away from Recordsets, use GetRows() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|