ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 31st, 2003, 12:19 PM
djjc djjc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 11 djjc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 29 sec
Reputation Power: 0
Data Order

I am new at ASP and trying to order the data i retive from the data base by veriable that represents any of the collum names in my Access data base.

I have opened my connection and named it objConn, then i have created a record set and assigned it to Projects.

I have also assigned a value to my variable calld Order - the string that this variable holds is one of the collum names in the data base.

I am attempting to use the following code to open my connection with the results orderd by the Order variable.


Projects.Open "SELECT * FROM Projects ORDER BY '" & Order & "' ", objConn


I don't get any errors when the page runs but it also do not order my data the way i asked it to.

I have checked the Order variable by printing it to the screen and it does in fact hold a string that matches the collum names.

I have also checked the Select statment without the variable by just typing in all of the posibilities that can be assigned to the Order variable and it works just fine.

So the problem must be when i add in the variable.

Thanks in advance for helping me out.

Reply With Quote
  #2  
Old November 5th, 2003, 10:01 AM
williamcrawley williamcrawley is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: uk
Posts: 91 williamcrawley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
looking at your statement you are wrapping the Order value in single quotes. Remove the single quote. YOu might also wish to add asc or desc to the order by clause.

Also run the complete SQL statement with the order value in the SQL Environment, to ensure the Syntax for the whole string is correct not just by looking at them seperately.

Reply With Quote
  #3  
Old November 5th, 2003, 11:14 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 13th Plane (11000 - 11499 posts)
 
Join Date: Jun 2003
Posts: 11,234 Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 7 h 12 m 7 sec
Reputation Power: 909
It's also possible that order is a sql "reserved word". Try putting [ ] around the column name, or rename the column.

Reply With Quote
  #4  
Old November 5th, 2003, 12:06 PM
DarrenMBrink DarrenMBrink is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Ohio
Posts: 30 DarrenMBrink User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 6 sec
Reputation Power: 6
Send a message via AIM to DarrenMBrink
Why don't you try setting up your db call in a record set like this,


set rsProject = server.createObject("ADODB.Recordset")
sqlStatement = "SELECT * FROM Projects ORDER BY " & Order
rsProject.Open sqlStatement, objConn, 0, 1


if not rsProject .eof and not rsProject.bof then
rsProject .movefirst

variableName = rsProject .fields("databaseFieldName")
variableName = rsProject .fields("databaseFieldName")
variableName = rsProject .fields("databaseFieldName")
variableName = rsProject .fields("databaseFieldName")

end if

rsProject .Close
set rsProject = nothing


The 0, 1 is assuming that you only want to read from this list and not write otherwise it would be 1, 3. That should work for you. And where ever you want your data to show just call the correct variable name and it should show. Here is a quick example

<table>
<tr>
<td><%= variableName1%>
</tr>
</table>

Let me know if this helps

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Data Order


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT