ASP (SQL) Sorting Newbie question

ASP (SQL) Sorting Newbie question

Post by Pierre Hen » Mon, 29 Sep 2003 16:20:10


Hi All,
I have an Access database on a remote server.
Everything works fine but I cannot manage to sort the
records alphabetically when the recordset opens.
I attach shortened extract of one of my many attempts:

Help/comments will be highly appreciated
Regards,
Pierre

After the connection has been established:

Dim sqlA
sqlA="SELECT ID,TNAME,TREG FROM conlist ORDER BY TNAME"
objD.Execute (sqlA)
objR.Open "conlist", objD, 0, 1
%>

'----------------------THE HTML TABLE HEADERS
ARE "DEFINED"


<Table bgcolor="#000080" width="888">
<TR>
<TD NO</td>
<TD NAME</td>
<TD REG. NO</td>
</TR>
</Table>

'----------------------LOOP THRU RECORDS
<%
do while not objR.EOF
%>
<table width="890">
<TD <%Response.Write objR("ID")%></b></td>
<TD <%Response.Write objR("TNAME")%></td>
<TD <%Response.Write objR("TREG")%></td>
</TR>
</Table>
<%
objR.MoveNext
loop
%>
 
 
 

ASP (SQL) Sorting Newbie question

Post by Jack Vamva » Mon, 29 Sep 2003 18:32:53

Try running the SQL statement in the SQL area of Access. Do you still get
the same problem?
If so, then you will need to troubleshoot the db.

If the sql statement works as you think it should in the sql panel of the
Access db, then you will need to troubleshhot
your script page.


___________________________________________________________________
Remotely manage MS SQL db with SQLdirector -
www.ciquery.com/tools/sqldirector/

 
 
 

ASP (SQL) Sorting Newbie question

Post by Walter Zac » Mon, 29 Sep 2003 19:30:34

How about:

Dim sqlA
sqlA="SELECT ID,TNAME,TREG FROM conlist ORDER BY TNAME"
Set objR = objD.Execute(sqlA)

With your original usage, you were instructing ADO to retrieve the sorted
recordset and then discard it. If you must use the open method in order to
set various options, you would do this instead.

Dim sqlA
sqlA="SELECT ID,TNAME,TREG FROM conlist ORDER BY TNAME"
objR.Open sqlA,objD,0,1



| Hi All,
| I have an Access database on a remote server.
| Everything works fine but I cannot manage to sort the
| records alphabetically when the recordset opens.
| I attach shortened extract of one of my many attempts:
|
| Help/comments will be highly appreciated
| Regards,
| Pierre
|
| After the connection has been established:
|
| Dim sqlA
| sqlA="SELECT ID,TNAME,TREG FROM conlist ORDER BY TNAME"
| objD.Execute (sqlA)
| objR.Open "conlist", objD, 0, 1
| %>
|
| '----------------------THE HTML TABLE HEADERS
| ARE "DEFINED"
|
|
| <Table bgcolor="#000080" width="888">
| <TR>
| <TD NO</td>
| <TD NAME</td>
| <TD REG. NO</td>
| </TR>
| </Table>
|
| '----------------------LOOP THRU RECORDS
| <%
| do while not objR.EOF
| %>
| <table width="890">
| <TD <%Response.Write objR("ID")%></b></td>
| <TD <%Response.Write objR("TNAME")%></td>
| <TD <%Response.Write objR("TREG")%></td>
| </TR>
| </Table>
| <%
| objR.MoveNext
| loop
| %>
|
 
 
 

ASP (SQL) Sorting Newbie question

Post by Pierre Hen » Tue, 30 Sep 2003 04:11:45

Thanks Jack and Walter.
Your responses are appreciated.
I will certainly try - and respond to your suggestions.
Best regards,
Pierre

retrieve the sorted
method in order to
 
 
 

ASP (SQL) Sorting Newbie question

Post by Pierre Hen » Tue, 30 Sep 2003 14:14:10

Thanks Walter - it works perfectly.
Regards,
Pierre