...

View Full Version : please help with "order by" in ASP



billykiet
03-22-2006, 12:07 AM
I have this:
SELECT * from truyen_truyenngan, truyen_titles, truyen_authors where truyen_titles.ID = truyen_truyenngan.title_ID and truyen_authors.ID=truyen_titles.title_authors and truyen_titles.ID =" & ID, truyen_GetDatabaseConn, 1,3

how do i add "order by" into that statement? please help

for example if i want to add "order by date desc" , please let me know how to insert this into the statement above.

thnks

lovesirius12
03-22-2006, 01:41 AM
I have this:
SELECT * from truyen_truyenngan, truyen_titles, truyen_authors where truyen_titles.ID = truyen_truyenngan.title_ID and truyen_authors.ID=truyen_titles.title_authors and truyen_titles.ID =" & ID, truyen_GetDatabaseConn, 1,3

how do i add "order by" into that statement? please help

for example if i want to add "order by date desc" , please let me know how to insert this into the statement above.

thnks

im using recordset, so if you want, you could try
set rs = server.createobject("ADODB.Recordset")
sql = "SELECT * from truyen_truyenngan, truyen_titles, truyen_authors where truyen_titles.ID = truyen_truyenngan.title_ID and truyen_authors.ID=truyen_titles.title_authors and truyen_titles.ID =" & ID & " order by truyen_truyenngan.date desc"

rs.cursortype = 1
rs.locktype = 3
rs.open truyen_GetDatabaseConn

billykiet
03-22-2006, 02:09 AM
this is the error i got after what you've showed me:

ADODB.Recordset error '800a0e7d'

The connection cannot be used to perform this operation. It is either closed or invalid in this context.

degsy
03-22-2006, 03:09 PM
Your syntax is not correct
http://www.w3schools.com/ado/ado_recordset.asp

Im_ok
03-24-2006, 12:30 PM
sql="SELECT * from truyen_truyenngan, truyen_titles, truyen_authors where truyen_titles.ID = truyen_truyenngan.title_ID and truyen_authors.ID=truyen_titles.title_authors and truyen_titles.ID = " & ID & " order by date desc"

set rs=truyen_GetDatabaseConn.execute(sql)

miranda
03-26-2006, 05:51 PM
"SELECT * from truyen_truyenngan, truyen_titles, truyen_authors where truyen_titles.ID = truyen_truyenngan.title_ID and truyen_authors.ID=truyen_titles.title_authors and truyen_titles.ID =" & ID & " ORDER BY truyen_authors", truyen_GetDatabaseConn, 1,3



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum