Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1494 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Need help with ORDER BY statement

Thread title: Need help with ORDER BY statement
Closed Thread    
    Thread tools Search this thread Display Modes  
04-02-2006, 12:43 PM
#1
nickmc is offline nickmc
nickmc's Avatar
Status: I'm new around here
Join date: Mar 2005
Location:
Expertise:
Software:
 
Posts: 23
iTrader: 0 / 0%
 

nickmc is on a distinguished road

  Old  Need help with ORDER BY statement

I need your expert help with this, im trying to sort the following by "Date" ive tried adding code here and there but nothing seems to work! the code below works fine and extracts data from the database but I can't see to get it to output by date order. This is connected to a MS Access database and the date format is short date format (dd/mm/yyyy). Im sure its pretty simple to do but I am new to ASP so please help me!

<%


Dim DBConn
Dim sDBString

sDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("chamber.mdb") & ";"

set DBConn = Server.CreateObject("ADODB.Connection")

'' Note: Open the database
DBConn.Open(sDBString)

SQLQuery = "SELECT * FROM Events"

Set DBOutput = DBConn.Execute(SQLQuery)
%>
<body text="#000000">
<p><font color="#FFFFFF">
<%Do While Not DBOutput.Eof%>
</font></p>
<p>&nbsp;</p>

<p><%=DBOutput("Date")%></p>
<p><%=DBOutput("Event")%></p>
<p>
<%=DBOutput("Time_held")%></p>
<p><%=DBOutput("Members_price")%></p>
<p>
<%=DBOutput("Non_members_price")%></p>
<p><%=DBOutput("Address")%></p>
<p>
<%=DBOutput("Speaker")%></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><font color="#FFFFFF">
<%
DBOutput.Movenext
Loop

DBConn.Close
Set DBOutput = Nothing
Set DBConn = Nothing
%>
</font> </p>
</body>
</html>

04-03-2006, 12:42 AM
#2
PCGuru is offline PCGuru
Status: I'm new around here
Join date: Apr 2006
Location:
Expertise:
Software:
 
Posts: 3
iTrader: 0 / 0%
 

PCGuru is on a distinguished road

  Old

off the top of my head - SQLQuery = "SELECT * FROM Events ORDER BY Date DESC"

If you want date in ascending order change DESC to ASC.

Theory is to order the result set in the basic query, then use the asp to output the result set as it stands.

Hope this helps, at least points you in the right direction!

04-03-2006, 10:23 AM
#3
nickmc is offline nickmc
nickmc's Avatar
Status: I'm new around here
Join date: Mar 2005
Location:
Expertise:
Software:
 
Posts: 23
iTrader: 0 / 0%
 

nickmc is on a distinguished road

  Old

PC Guru you are a guru! that worked perfectly! I was just writting the code slightly wrong but what you said worked! Thanks!

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed