473,320 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Ordering data from SQL/ASP

Hi there,

I have an application that rips data from an SQL server and displays it in
columnar form on an ASP page, using a
Do until RS.EOF loop.

I wish to add 2 arrows to each column (up and down) and when clicked, orders
the data on the page by that column (up - A-Z and down Z-A etc.....)
Is this possible in ASP or would i need some Javascript/Client side code to
do this?

The problem is the ASP SELECT statement orders the data initially, i just
need to know how the user can re-order the data after it is on the page?

Any ideas/examples much appreciated.
--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
Jul 19 '05 #1
13 1707
Fawke101 wrote:
Hi there,

I have an application that rips data from an SQL server and displays
it in columnar form on an ASP page, using a
Do until RS.EOF loop.

I wish to add 2 arrows to each column (up and down) and when clicked,
orders the data on the page by that column (up - A-Z and down Z-A
etc.....)
Is this possible in ASP or would i need some Javascript/Client side
code to do this?

The problem is the ASP SELECT statement orders the data initially, i
just need to know how the user can re-order the data after it is on
the page?

Any ideas/examples much appreciated.


You will need client-side code for this. You should be able to find examples
via a Google search using the keywords:

DHTML sort table columns

Please follow up in a client-side newsgroup: look for a newsgroup with
"dhtml" in its name, or go to one of the .scripting groups.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #2
I use ASP to do it it just requires another trip to the
server. Build hyperlinks out of the arrows and pass your
sort instructions through the querystring. I pass "U"
or "D" for Asending or Desending then build your order for
you select statement from that.

I would post sample code but my server is currently off.
If I get my server up I will post back later.

Mike

-----Original Message-----
Hi there,

I have an application that rips data from an SQL server and displays it incolumnar form on an ASP page, using a
Do until RS.EOF loop.

I wish to add 2 arrows to each column (up and down) and when clicked, ordersthe data on the page by that column (up - A-Z and down Z- A etc.....)Is this possible in ASP or would i need some Javascript/Client side code todo this?

The problem is the ASP SELECT statement orders the data initially, i justneed to know how the user can re-order the data after it is on the page?
Any ideas/examples much appreciated.
--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
.

Jul 19 '05 #3
Thanks for that Bob, i have joint posted this to a client side newsgroup so
hopefully should get some more feedback from there,

Thanks again

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
Fawke101 wrote:
Hi there,

I have an application that rips data from an SQL server and displays
it in columnar form on an ASP page, using a
Do until RS.EOF loop.

I wish to add 2 arrows to each column (up and down) and when clicked,
orders the data on the page by that column (up - A-Z and down Z-A
etc.....)
Is this possible in ASP or would i need some Javascript/Client side
code to do this?

The problem is the ASP SELECT statement orders the data initially, i
just need to know how the user can re-order the data after it is on
the page?

Any ideas/examples much appreciated.
You will need client-side code for this. You should be able to find

examples via a Google search using the keywords:

DHTML sort table columns

Please follow up in a client-side newsgroup: look for a newsgroup with
"dhtml" in its name, or go to one of the .scripting groups.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #4
Fawke101 wrote:
Thanks for that Bob, i have joint posted this to a client side
newsgroup so hopefully should get some more feedback from there,

Yes, I did not notice the crosspost until I saw your message in the other
group. Thank you for crossposting instead of multiposting.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #5
You may find client-side code but if your table is large this code may be
too slow. The possible solution is to reload web-page when user presses a
button and pass parameter to the page that specifies sort column:

http://mydomain.com/mypage.asp?sort=mycolumn

and refill table on server with ORDER BY in SQL according sort parameter.

//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE

"Fawke101" <gu*@ANTIbradflack.SPAMcom> сообщил/сообщила в новостях
следующее: news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi there,

I have an application that rips data from an SQL server and displays it in
columnar form on an ASP page, using a
Do until RS.EOF loop.

I wish to add 2 arrows to each column (up and down) and when clicked, orders the data on the page by that column (up - A-Z and down Z-A etc.....)
Is this possible in ASP or would i need some Javascript/Client side code to do this?

The problem is the ASP SELECT statement orders the data initially, i just
need to know how the user can re-order the data after it is on the page?

Any ideas/examples much appreciated.
--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com

Jul 19 '05 #6
Viatcheslav V. Vassiliev wrote:
You may find client-side code but if your table is large this code
may be too slow. The possible solution is to reload web-page when
user presses a button and pass parameter to the page that specifies
sort column:

http://mydomain.com/mypage.asp?sort=mycolumn

and refill table on server with ORDER BY in SQL according sort
parameter.


A client-side solution does not have to involve bringing the entire table to
the client. For example, XMLHTTP can be used to request data from a
server-side page.

If this is not a "paging" situation, then the client already has all the
data, which can be sorted in client-side code. Why waste time and resources
by going back to the server? Of course, if you are paging through the data,
then you probably will need to go back to the server for data since the new
sort order might require that a different page of data be displayed.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #7
Hi there,

The data displayed on the page is the data displayed on the page. No paging
situation is apparent and the client side code definately sounds the most
efficient in my situation. This is not a complex site, just ripping and
displaying data.

Could anyone give me any more specifics on how i can do this in JS/DHTML??

Thanks

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
Viatcheslav V. Vassiliev wrote:
You may find client-side code but if your table is large this code
may be too slow. The possible solution is to reload web-page when
user presses a button and pass parameter to the page that specifies
sort column:

http://mydomain.com/mypage.asp?sort=mycolumn

and refill table on server with ORDER BY in SQL according sort
parameter.

A client-side solution does not have to involve bringing the entire table

to the client. For example, XMLHTTP can be used to request data from a
server-side page.

If this is not a "paging" situation, then the client already has all the
data, which can be sorted in client-side code. Why waste time and resources by going back to the server? Of course, if you are paging through the data, then you probably will need to go back to the server for data since the new sort order might require that a different page of data be displayed.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #8
Fawke101 wrote:
Hi there,

The data displayed on the page is the data displayed on the page. No
paging situation is apparent and the client side code definately
sounds the most efficient in my situation. This is not a complex
site, just ripping and displaying data.

Could anyone give me any more specifics on how i can do this in
JS/DHTML??

Did you try the Google search? I saw several examples when I tried the
keywords I recommended earlier. In fact, the very first hit from that search
was this:

http://www.kryogenix.org/code/browser/sorttable/

It looks very slick.

I know there have been several articles about how to do this on the
4GuysFromRolla site.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #9
Even in non-paging situation requesting data from server could be faster.
That is because HTML DOM does not have methods like
beginUpdate()\endUpdate() and when re-arranging rows web-page will be
updated (repainted) on every operation - even on medium-size dataset this
can be very time consuming. Solutions that store data on client-side outside
table and create table on the fly will require much coding and probably will
not be browser independent.

Plus with request to the server client will have refreshed data with
updates/deletes that happened in last minutes/seconds.

//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> сообщил/сообщила в новостях
следующее: news:OA**************@TK2MSFTNGP09.phx.gbl...
Viatcheslav V. Vassiliev wrote:
You may find client-side code but if your table is large this code
may be too slow. The possible solution is to reload web-page when
user presses a button and pass parameter to the page that specifies
sort column:

http://mydomain.com/mypage.asp?sort=mycolumn

and refill table on server with ORDER BY in SQL according sort
parameter.

A client-side solution does not have to involve bringing the entire table

to the client. For example, XMLHTTP can be used to request data from a
server-side page.

If this is not a "paging" situation, then the client already has all the
data, which can be sorted in client-side code. Why waste time and resources by going back to the server? Of course, if you are paging through the data, then you probably will need to go back to the server for data since the new sort order might require that a different page of data be displayed.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #10
ok, do you have any more details on this, or any links to sites, as i seem
to be returning few relevant hits on google?

Thanks again

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
"Viatcheslav V. Vassiliev" <ms*********@www-sharp.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
Even in non-paging situation requesting data from server could be faster.
That is because HTML DOM does not have methods like
beginUpdate()\endUpdate() and when re-arranging rows web-page will be
updated (repainted) on every operation - even on medium-size dataset this
can be very time consuming. Solutions that store data on client-side outside table and create table on the fly will require much coding and probably will not be browser independent.

Plus with request to the server client will have refreshed data with
updates/deletes that happened in last minutes/seconds.

//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> сообщил/сообщила в новостях
следующее: news:OA**************@TK2MSFTNGP09.phx.gbl...
Viatcheslav V. Vassiliev wrote:
You may find client-side code but if your table is large this code
may be too slow. The possible solution is to reload web-page when
user presses a button and pass parameter to the page that specifies
sort column:

http://mydomain.com/mypage.asp?sort=mycolumn

and refill table on server with ORDER BY in SQL according sort
parameter.

A client-side solution does not have to involve bringing the entire

table to
the client. For example, XMLHTTP can be used to request data from a
server-side page.

If this is not a "paging" situation, then the client already has all the
data, which can be sorted in client-side code. Why waste time and

resources
by going back to the server? Of course, if you are paging through the

data,
then you probably will need to go back to the server for data since the

new
sort order might require that a different page of data be displayed.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Jul 19 '05 #11
On Mon, 22 Mar 2004 17:45:56 -0000, "Fawke101"
<gu*@ANTIbradflack.SPAMcom> wrote:
ok, do you have any more details on this, or any links to sites, as i seem
to be returning few relevant hits on google?


This site has a list of methods for you:

http://www.google.com/search?hl=en&i...ipt+table+sort

And yes, it's a Google search. For "javascript table sort" which
seemed pretty obvious to search on. And the first 42 links all are
right on the topic you're asking about. Could be more but I figured
after checking 42 I'd done *way* too much of your work and that you
need to get some experience under your belt as well.

I have the feeling that these won't help you either though, since I
don't think you have the background or experience to understand them
based on your posts, so you may need to start with something a little
less daunting and work through some tutorials first.

Jeff
Jul 19 '05 #12
Your code may look like (look for line breaks):

<% @Language="JScript"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta name="GENERATOR" content="MSHTML 6.00.2800.1400">
<script>
function sortDesc(column)
{
//replace test.asp with valid address
window.navigate("test.asp?sort=" + column + "&dir=desc");
}

function sortAsc(column)
{
//replace test.asp with valid address
window.navigate("test.asp?sort=" + column);
}
</script>
</head>
<body>
<%
var conn = Server.CreateObject("ADODB.Connection");
var rs = null;

var strSQL = "SELECT * FROM [Customers]";

if (Request.QueryString("sort").Count > 0)
{
var strSort = Request.QueryString("sort");
strSQL += " ORDER BY [" + strSort + "]";

if (Request.QueryString("dir").Count > 0)
{
var strDir = Request.QueryString("dir");
if (strDir == "desc") strSQL += " DESC";
}
}
else
{
//Apply default sort order
}

conn.Open("Provider=SQLOLEDB;Integrated Security=SSPI;Initial
catalog=Northwind;");
rs = conn.Execute(strSQL);
%>
<table border="1">
<thead>
<tr>
<%
for (i = 0; i < rs.Fields.Count; i++)
{
var fldName = rs.Fields(i).Name;
Response.Write("<TH>" + fldName + "<BR>");
Response.Write("<BUTTON onclick=\"sortAsc('" + fldName +
"')\">A</BUTTON>");
Response.Write("<BUTTON onclick=\"sortDesc('" + fldName +
"')\">V</BUTTON>");
Response.Write("</TH>\r\n");
}
%>
</tr>
</thead>
<tbody>
<tr>
<%
rs.MoveFirst();
while (!rs.EOF)
{
Response.Write("<TR>\r\n");

for (i = 0; i < rs.Fields.Count; i++)
{
Response.Write("<TD>" + rs.Fields(i).Value + "</TD>\r\n");
}

Response.Write("</TR>\r\n");
rs.MoveNext();
}
%>
</tr>
</tbody>
</table>
</body>
</html>

"Fawke101" <gu*@ANTIbradflack.SPAMcom> сообщил/сообщила в новостях
следующее: news:e0**************@TK2MSFTNGP10.phx.gbl...
ok, do you have any more details on this, or any links to sites, as i seem
to be returning few relevant hits on google?

Thanks again

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
"Viatcheslav V. Vassiliev" <ms*********@www-sharp.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
Even in non-paging situation requesting data from server could be faster. That is because HTML DOM does not have methods like
beginUpdate()\endUpdate() and when re-arranging rows web-page will be
updated (repainted) on every operation - even on medium-size dataset this can be very time consuming. Solutions that store data on client-side

outside
table and create table on the fly will require much coding and probably

will
not be browser independent.

Plus with request to the server client will have refreshed data with
updates/deletes that happened in last minutes/seconds.

//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> сообщил/сообщила в новостях следующее: news:OA**************@TK2MSFTNGP09.phx.gbl...
Viatcheslav V. Vassiliev wrote:
> You may find client-side code but if your table is large this code
> may be too slow. The possible solution is to reload web-page when
> user presses a button and pass parameter to the page that specifies
> sort column:
>
> http://mydomain.com/mypage.asp?sort=mycolumn
>
> and refill table on server with ORDER BY in SQL according sort
> parameter.
>

A client-side solution does not have to involve bringing the entire table
to
the client. For example, XMLHTTP can be used to request data from a
server-side page.

If this is not a "paging" situation, then the client already has all the data, which can be sorted in client-side code. Why waste time and

resources
by going back to the server? Of course, if you are paging through the

data,
then you probably will need to go back to the server for data since

the new
sort order might require that a different page of data be displayed.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Jul 19 '05 #13
Viatcheslav V. Vassiliev wrote:
Even in non-paging situation requesting data from server could be
faster. That is because HTML DOM does not have methods like
beginUpdate()\endUpdate() and when re-arranging rows web-page will be
updated (repainted) on every operation -
This is totally contrary to my experience. I never perceive a repaint until
the entire table resort is completed. In fact, there have been times I've
wanted to write something to the screen during this type of operation and
have been unable to without using settimeout.
even on medium-size dataset
this can be very time consuming. Solutions that store data on
client-side outside table and create table on the fly will require
much coding and probably will not be browser independent.
I can't argue with the browser independence, but I'm sure code could be
written that is compatible with most browsers.

Plus with request to the server client will have refreshed data with
updates/deletes that happened in last minutes/seconds.


If that is a concern, then of course one needs to refresh the data from the
database. If not, there is no point in making another trip to the server.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: nospam | last post by:
NEWS.COM Amazon wins patent for ordering forms # 6,615,226 http://tinyurl.com/m7v8 http://news.com.com/2100-1017-5070569.html In its latest patent, the online retailing giant outlined a...
6
by: Brendan.Collins | last post by:
Hi I have a javascript problem that has been annoying me for two days now and thought that a javascript expert might have the magic solution. I am populating a table dynamically from the...
9
by: Rick | last post by:
I've created a clustered two column index on a table where the second column is an integer value. When the first column is the same, instead of ordering in numerical order it is ordering...
2
by: D. Dante Lorenso | last post by:
First I created a function that selected the next available pin code from a table of pre-defined pin codes: CREATE FUNCTION "public"."get_next_pin_code" () RETURNS varchar AS' DECLARE...
3
by: marc | last post by:
I want to create a strongly typed collection and use DictionaryBase I add a number of objects but when i loop through the list the data is ordered in a strange maner. How is this possible? Can...
1
by: Matt Roberts | last post by:
Please accept my apologies if this is answered elsewhere in the archives or docs but I have searched without luck. I've always assumed that default ordering of selects are based on a first in...
33
by: Benjamin M. Stocks | last post by:
Hello all, I've heard differing opinions on this and would like a definitive answer on this once and for all. If I have an array of 4 1-byte values where index 0 is the least signficant byte of a...
5
by: =?Utf-8?B?VG9t?= | last post by:
Cannot not seem to make any sense of the order that my key/values end up in when added to the Hashtable...ideally, I would like to be able to sort the keys/values...but not thinking it is possible....
36
by: dspfun | last post by:
Hi! Is there any way in C that one can guarantee that instructions are executed in the same order as they are written in the program? For example, say I have the following: instruction1;...
4
by: Andrevv | last post by:
Hi all! Im totaly new in programing, so i need some help if someone can help me... Im programing in VS 2005, C# language and using MS SQL Server 2005 . So, after i fill my table with 10 records,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you▓ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.