PDA

View Full Version : ADO ORDER BY in Javascript



LFCFan
12-19-2006, 06:23 PM
Hi All,

I wasn't sure whether to post in the Javascript forums or in here, but having googled around, I can't find any clear explanation on the problems with ADO and the usage of ORDER BY through Javascript. I'm trying to Order the results of an SQL query from an Access 97 Database and failing miserably. No errors are thrown, but the sort order doesn't change either.

Browser: MSIE6SP1
OS: Windows NT 4.0
MDAC: 2.5

Any help, or pointers to any useful info would be most appreciated!

Thanks
Joe

Brandoe85
12-19-2006, 08:49 PM
I've never used client side ado, but what's the query look like that you are trying to order? What order by clause did you try?

LFCFan
12-21-2006, 10:17 AM
Hi Brando,

Thanks for getting back to me.

This is a brief look at my string:


User selects an option here:

<select name = "ascDesc" id = 'upDown'>
<option selected value =0>
<option value = 1>ASC
<option value = 2>DESC
</option>
</select>

Then the result of this is sent to the script which makes this line:

var qString="SELECT * FROM QAGrades WHERE " + qTypeUser + " " + op + " " + "'" + strVal + "'" + " ORDER BY " + "'" + oBySetUp + "' " + ascDesc

QAGrades is the table I'm querying. qTypeUser is a variable to store the query type (numeric or text). op is the operator they will be using (<, > or = for now). strVal is the string value. then we get to ORDER BY. oBySetUp sets up the order by string (generated from a select box). Then ascDesc is either ASC or DESC from the select box above. generated text-type query string would look like this:

SELECT * FROM QAGrades WHERE QAGrades.`User Id` = 'FosterJ' ORDER BY 'QAGrades.`Record Number`' ASC

Hope this makes some sense. Everything works fine up until the ORDER BY part, which seems to be ignored whatever I ask for.

Thanks for the help
Joe