Search Tools Links Login

Client Side Sorting of records


THIS CODE WILL CONVERT A RECORDSET INTO A CLIENT SIDE ARRAY AND THIS ARRAY CAN BE SORTED AS PER ANY FIELD IN THE TABLE.SINCE THE PROCESSING IS DONE ON THE CLIENT SIDE ITSELF PERFORMANCE IS MUCH BETTER.CLICKING ON THE HYPERLINKED TABLE COLUMN HEADERS WILL CSORT THE RECORDS AS PER THAT COLUMN.

Original Author: Ravi Rajan

Assumptions

JUST REPLACE THE CONNECTION STRING WITH YOUR SQL-SERVER CONNECTION AND THE CODE IS READY TO RUN

Returns

SORTED CLIENT SIDE ARRAY

Code

<%
dim conn
dim strconn
dim objrs
dim strsql
set conn=server.CreateObject("ADODB.connection")
set objrs=server.CreateObject("ADODB.recordset")
strconn="Provider=SQLOLEDB.1;Password=efc;Persist Security Info=True;User ID=test;Initial Catalog=Northwind;Data Source=SMARTEPRD"
conn.ConnectionString=strconn
conn.Open

strsql="SELECT P.PRODUCTNAME AS PRODUCT,C.CATEGORYNAME AS CATEGORY,S.COMPANYNAME AS SUPPLIER " & _
"FROM PRODUCTS P,CATEGORIES C,SUPPLIERS S WHERE " & _
"P.CATEGORYID=C.CATEGORYID AND " & _
"P.SUPPLIERID=S.SUPPLIERID " & _
"ORDER BY P.PRODUCTNAME "
objrs.Open strsql,conn
%>



<%
'converting recordset into a client side array
dim nor
while not objrs.EOF
nor=nor+1
objrs.MoveNext
wend
objrs.MoveFirst
Response.Write("")
%>



Client Side Sorting Using ARRAY Object's SORT METHOD









ProductCategorySupplier


About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 112 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.