Question

How can I order data by column by clicking on hypertext in an ASP project?

Asked by: kfranck

I have created an ASP project that I want to be able to sort the 7 column fields by clicking on the name of each field name.

For example, the name of the fields are "Ad Number", "Date", "Account Name/Number", "Completed", "Digital Component", "Priority" and "Start/End Date." Say I want to order by Date, I would click on Date (which would be a hyperlink) and it would sort by date. Same situation for all the other fields.

How can I do this? I have included the code of the ASP page as a text document. Thanks.
kfranck

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-08 at 08:22:27ID24881684
Topic

Active Server Pages (ASP)

Participating Experts
2
Points
500
Comments
45

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. DataGrid - Hyperlink/Data column
    On my DataGrid I have a column which returns data. I also want this column to be a hyperlink which passes a querystring which is data returned from another column (but same row). It seems I have a choice of a data column or a hyperlink column but not both. How do I do this...
  2. Hyperlink Column in Datagrid
    Anyone know how to make a Hyperlink column in the datagrid open a new window? And... with more than one parameter passed to it? For example... after adding data (dynamically at run time) to the grid, and then putting a hyperlink column in... Dim bc as New HyperLinkColumn b...
  3. Hyperlink in DataGrid Column
    I am reading in an xml file and the data in the first column (Field 1) are all web links (http://www.msn.com, etc, etc). Making the first column an asp:HyperLinkColumn, how can I get each row to hyperlink to the contents of that Field1? Here is my code: <asp:DataGrid id=&...
  4. <asp:HyperLink not evaluating the column in DataGridView
    Hi, I have the following inside of a DataGridView: <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="DealEntry.aspx?TradeId='<%#Eval('TradeId')%>'" Text='Select'></asp:...
  5. How to add a hyperlink programmatically to column in DataT…
    I'm trying to figure out how I can add a hyperlink to the "assign" column of my DataTable so that when I bind to my DataGrid, it shows that hyperlink. Please loko at both my DataGrid's assign column synt and the assign clumn and row syntax as I acnnot figure out th...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: mayankagarwalPosted on 2009-11-08 at 09:01:56ID: 25770994

To do this, you have to make the column headin hyperlink.
On clicking the hyperlink you have to agian call the same page with the sorted data.
Suppose the user click on "Ad Number", then while calling the asp page again have a querystring with url which have a variable say sort_order = adn
in the starting of the code define a variable sort_order
then have a if else loop like
if sort_order = "adn" then
     select * from table_name order_by ad_number"
else if sort_order = ...
.....
....
....
end if
end if
..
...
...
...
...

 

by: kfranckPosted on 2009-11-08 at 11:40:15ID: 25771572

I kind of understand. But I need your help in getting it going, if you will, please.

Say we use Ad Number, which is "AdNumber" in the table. The table is called "projects". Would that part of the code be:

if sort_order = "adn" then
     select * from projects order_by AdNumber"
else if sort_order = ... (what here)

End If  

Also I need help on the querysting with URL.

Thanks.

 

by: meeran03Posted on 2009-11-08 at 21:37:29ID: 25773588

Hi  Kfrank,

try This .

<a href="date.asp?sort_order=adn">date</a>
<a href="date.asp?sort_order=com"> Completed </a>
<a href="date.asp?sort_order=pri"> Priority </a>  
'On Clicking Any of the Link 
 
'Get The Query String Value   
sort_order = Request.QueryString("sort_order") 
sort_order = Replace(sort_order,"'","")  ' Avoid Error  
order_condn ="" 
If  sort_order = "adn" Then 
order_condn  = "order by adn desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn 
elseif sort_order="com" then
order_condn  = "order by com desc"
elseif sort_order="pri" then 
order_condn  = "order by pri desc"
End if  
Set SQL = yourconxn.Execute("Select * from projects"& order_condn)  
    
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:

Select allOpen in new window

 

by: kfranckPosted on 2009-11-09 at 06:55:08ID: 25776380

Thanks. Quick question if the name of the ASP page is "queue.asp", then I should change the <a href statement to "queue.asp" from "date.asp"? Right?

Also I have included the entire ASP (minus html) code below to make sure I put in the correct place. Is this correct?

<%
'Dimension variables
Dim adoCon 			'Holds the Database Connection Object
Dim rsMasterRolodex			'Holds the recordset for the records in the database
Dim strSQL			'Holds the SQL query for the database 
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection") 
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("digitalmedia.mdb") 
'Create an ADO recordset object
Set rsprojects = Server.CreateObject("ADODB.Recordset") 
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT projects.* FROM projects ORDER BY Completed;" 
'Open the recordset with the SQL query 
rsprojects.Open strSQL, adoCon 
<a href="date.asp?sort_order=adn">date</a>
<a href="date.asp?sort_order=com"> Completed </a>
<a href="date.asp?sort_order=pri"> Priority </a>  
'On Clicking Any of the Link 
 
'Get The Query String Value   
sort_order = Request.QueryString("sort_order") 
sort_order = Replace(sort_order,"'","")  ' Avoid Error  
order_condn ="" 
If  sort_order = "adn" Then 
order_condn  = "order by adn desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn 
elseif sort_order="com" then
order_condn  = "order by com desc"
elseif sort_order="pri" then 
order_condn  = "order by pri desc"
End if  
Set SQL = yourconxn.Execute("Select * from projects"& order_condn)  
    
Dim counter
 counter=0
'Loop through the recordset
    Do While not rsprojects.EOF
    counter=counter+1
    'Write the HTML to display the current record in the recordset
     IF 0=(counter Mod 2) Then      
             Response.Write "<tr class='even'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      Else
            Response.Write "<tr class='odd'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      End If
    Response.Write "<td>" & rsprojects.Fields("Date") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:maroon;'>" & rsprojects.Fields("AccountNameNumber") & "</td>" 
    Response.Write "<td>" & rsprojects.Fields("Completed") & "</td>"
    Response.Write "<td>" & rsprojects.Fields("DigitalComponent") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("Priority") & "</td>"     
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("StartEndDate") & "</td>"
    Response.Write "</tr>"      
					
	'Move to the next record in the recordset
	 rsprojects.MoveNext
	Loop
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:

Select allOpen in new window

 

by: meeran03Posted on 2009-11-09 at 07:19:27ID: 25776609

Hi ,


1>>if the name of the ASP page is "queue.asp",??
<a href=""></a>
Here Watever you give it will be redirected to the respective page . Make Sure That Link Exists in your folder .

2>>For your Info
<%%>-->This is Server Tag and so it should contain only server side code as here we use Vbscript .

<% - This is Start Of Server Tag
Server side Code Will be Executed
%> --End Of Tag


I had framed my previous code to below ....



<%
'Dimension variables
Dim adoCon 			'Holds the Database Connection Object
Dim rsMasterRolodex			'Holds the recordset for the records in the database
Dim strSQL			'Holds the SQL query for the database 
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection") 
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("digitalmedia.mdb") 
'Create an ADO recordset object
Set rsprojects = Server.CreateObject("ADODB.Recordset") 
'Initialise the strSQL variable with an SQL statement to query the database
%>  <!-- Server Tag Ends So now onwards Below Text is a HTML--> 
<a href="queue.asp?sort_order=adn">date</a> |
<a href="queue.asp?sort_order=com"> Completed </a> |
<a href="queue.asp?sort_order=pri"> Priority </a>   
<% ' Again Server Tag started 
'Get The Query String Value  
sort_order="" 
sort_order = Request.QueryString("sort_order") 
sort_order = Replace(sort_order,"'","")  ' Avoid Error  
order_condn ="" 
If  sort_order = "adn" Then 
order_condn  = "order by adn desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn 
elseif sort_order="com" then
order_condn  = "order by com desc"
elseif sort_order="pri" then 
order_condn  = "order by pri desc"
End if    
If isnull(sort_order) or sort_order = "" then 
strSQL = "SELECT projects.* FROM projects ORDER BY Completed;"  ' This just Loads By Completed ORder in ut queue.asp page 
else 
strSQL = "Select * from projects"& order_condn                   ' This Make sure to order accordingly to the click of the href . 
End if  
rsprojects.Open strSQL, adoCon 
    
Dim counter
 counter=0
'Loop through the recordset
    Do While not rsprojects.EOF
    counter=counter+1
    'Write the HTML to display the current record in the recordset
     IF 0=(counter Mod 2) Then      
             Response.Write "<tr class='even'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      Else
            Response.Write "<tr class='odd'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      End If
    Response.Write "<td>" & rsprojects.Fields("Date") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:maroon;'>" & rsprojects.Fields("AccountNameNumber") & "</td>" 
    Response.Write "<td>" & rsprojects.Fields("Completed") & "</td>"
    Response.Write "<td>" & rsprojects.Fields("DigitalComponent") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("Priority") & "</td>"     
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("StartEndDate") & "</td>"
    Response.Write "</tr>"      
					
	'Move to the next record in the recordset
	 rsprojects.MoveNext
	Loop
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:

Select allOpen in new window

 

by: kfranckPosted on 2009-11-09 at 17:26:08ID: 25781716

Thanks for all your help. We are getting really close to nailing this down.

I did get this error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
/digital/queue.asp, line 103

Line 103 is:
rsprojects.Open strSQL, adoCon

Suggestions?

 

by: meeran03Posted on 2009-11-09 at 19:35:50ID: 25782174

Give a Space while assigning condition may be this throwing u an error .....

order_condn  = "(space)order by adn desc"
order_condn  = "(space)order by com desc"
order_condn  = "(space)order by pri desc"



if it Still continue..
Just print ur query n run it in db ..n check whether u r getting syntax error of ur query

If  sort_order = "adn" Then 
'-------------------- Space 
'               | 
order_condn  = " order by adn desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn 
elseif sort_order="com" then
order_condn  = " order by com desc"
elseif sort_order="pri" then 
order_condn  = " order by pri desc"
End if 
If isnull(sort_order) or sort_order = "" then 
strSQL = "SELECT projects.* FROM projects ORDER BY Completed;"  ' This just Loads By Completed ORder in ut queue.asp page 
else 
strSQL = "Select * from [projects]"& order_condn                   ' This Make sure to order accordingly to the click of the href . 
End if  
'Try to print your Sql Statement and check in database 
'REsponse.write(strSQL)
'Response.end()
rsprojects.Open strSQL, adoCon  ' While Printing Hidden this line

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:

Select allOpen in new window

 

by: kfranckPosted on 2009-11-09 at 20:01:10ID: 25782289

I tried both suggestions, but I am still getting this error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
/digital/queue.asp, line 103

 

by: meeran03Posted on 2009-11-09 at 20:05:54ID: 25782304

Can u print the strSQL   statement and send me...??

 

by: mayankagarwalPosted on 2009-11-09 at 20:09:45ID: 25782316

PLEASE GIVE THE EXACT CODE WHAT YOU ARE EXECUTNG

 

by: kfranckPosted on 2009-11-09 at 20:25:18ID: 25782402

mayankagarwal:

Here is the code,

<%
'Dimension variables
Dim adoCon                   'Holds the Database Connection Object
Dim rsMasterRolodex                  'Holds the recordset for the records in the database
Dim strSQL                  'Holds the SQL query for the database
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("digitalmedia.mdb")
'Create an ADO recordset object
Set rsprojects = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
%>  <!-- Server Tag Ends So now onwards Below Text is a HTML-->
<a href="queue.asp?sort_order=adn">Date</a> |
<a href="queue.asp?sort_order=com"> Completed </a> |
<a href="queue.asp?sort_order=pri"> Priority </a>  
<% ' Again Server Tag started
'Get The Query String Value  
sort_order=""
sort_order = Request.QueryString("sort_order")
sort_order = Replace(sort_order,"'","")  ' Avoid Error  
order_condn =""
If  sort_order = "adn" Then
'-------------------- Space
'               |
order_condn  = " order by adn desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn
elseif sort_order="com" then
order_condn  = " order by com desc"
elseif sort_order="pri" then
order_condn  = " order by pri desc"
End if
If isnull(sort_order) or sort_order = "" then
strSQL = "SELECT projects.* FROM projects ORDER BY Completed;"  ' This just Loads By Completed ORder in ut queue.asp page
else
strSQL = "Select * from [projects]"& order_condn                   ' This Make sure to order accordingly to the click of the href .
End if  
'Try to print your Sql Statement and check in database
'REsponse.write(strSQL)
'Response.end()
rsprojects.Open strSQL, adoCon  ' While Printing Hidden this line
   
Dim counter
 counter=0
'Loop through the recordset
    Do While not rsprojects.EOF
    counter=counter+1
    'Write the HTML to display the current record in the recordset
     IF 0=(counter Mod 2) Then      
             Response.Write "<tr class='even'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      Else
            Response.Write "<tr class='odd'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      End If
    Response.Write "<td>" & rsprojects.Fields("Date") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:maroon;'>" & rsprojects.Fields("AccountNameNumber") & "</td>"
    Response.Write "<td>" & rsprojects.Fields("Completed") & "</td>"
    Response.Write "<td>" & rsprojects.Fields("DigitalComponent") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("Priority") & "</td>"    
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("StartEndDate") & "</td>"
    Response.Write "</tr>"      
                              
      'Move to the next record in the recordset
       rsprojects.MoveNext
      Loop
%>

 

by: kfranckPosted on 2009-11-09 at 20:26:53ID: 25782410

meeran03:

Pardon me, but I am unclear how to print the strsql statement.
kfranck

 

by: mayankagarwalPosted on 2009-11-09 at 20:28:24ID: 25782418

It would be great if you could tell me which is line no. 103

 

by: meeran03Posted on 2009-11-09 at 20:33:53ID: 25782434

Just replace with this line on your current code.. and execute .. This will write your strSql Statement

Response.write(strSQL)    
Response.end()
'rsprojects.Open strSQL, adoCon

<%
'Dimension variables
Dim adoCon                   'Holds the Database Connection Object
Dim rsMasterRolodex                  'Holds the recordset for the records in the database
Dim strSQL                  'Holds the SQL query for the database 
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection") 
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("digitalmedia.mdb") 
'Create an ADO recordset object
Set rsprojects = Server.CreateObject("ADODB.Recordset") 
'Initialise the strSQL variable with an SQL statement to query the database
%>  <!-- Server Tag Ends So now onwards Below Text is a HTML--> 
<a href="queue.asp?sort_order=adn">Date</a> |
<a href="queue.asp?sort_order=com"> Completed </a> |
<a href="queue.asp?sort_order=pri"> Priority </a>   
<% ' Again Server Tag started 
'Get The Query String Value  
sort_order="" 
sort_order = Request.QueryString("sort_order") 
sort_order = Replace(sort_order,"'","")  ' Avoid Error  
order_condn ="" 
If  sort_order = "adn" Then 
'-------------------- Space 
'               | 
order_condn  = " order by adn desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn 
elseif sort_order="com" then
order_condn  = " order by com desc"
elseif sort_order="pri" then 
order_condn  = " order by pri desc"
End if 
If isnull(sort_order) or sort_order = "" then 
strSQL = "SELECT projects.* FROM projects ORDER BY Completed;"  ' This just Loads By Completed ORder in ut queue.asp page 
else 
strSQL = "Select * from [projects]"& order_condn                   ' This Make sure to order accordingly to the click of the href . 
End if  
'Try to print your Sql Statement and check in database 
REsponse.write(strSQL)
Response.end()
'rsprojects.Open strSQL, adoCon  
    
Dim counter
 counter=0
'Loop through the recordset
    Do While not rsprojects.EOF
    counter=counter+1
    'Write the HTML to display the current record in the recordset
     IF 0=(counter Mod 2) Then      
             Response.Write "<tr class='even'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      Else
            Response.Write "<tr class='odd'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      End If
    Response.Write "<td>" & rsprojects.Fields("Date") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:maroon;'>" & rsprojects.Fields("AccountNameNumber") & "</td>" 
    Response.Write "<td>" & rsprojects.Fields("Completed") & "</td>"
    Response.Write "<td>" & rsprojects.Fields("DigitalComponent") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("Priority") & "</td>"     
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("StartEndDate") & "</td>"
    Response.Write "</tr>"      
                              
      'Move to the next record in the recordset
       rsprojects.MoveNext
      Loop
%>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:

Select allOpen in new window

 

by: mayankagarwalPosted on 2009-11-09 at 20:35:44ID: 25782442

You are getting error on line 103
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
/digital/queue.asp, line 103
But the code that you have given is till line 64 please clearify

 

by: kfranckPosted on 2009-11-09 at 20:37:41ID: 25782445

Line 103 is

rsprojects.Open strSQL, adoCon

 

by: mayankagarwalPosted on 2009-11-09 at 20:39:19ID: 25782454

This is an error in your connection file please check the same

 

by: kfranckPosted on 2009-11-09 at 20:46:08ID: 25782480

Do this, please. Go to this URL:
http://toledobladedata.com/digital/queue.asp

If you click on Date | Completed | Priority, you get the error.

If you click on hypertext under the Ad Number column, the connection works fine and it takes you to the next page.

 

by: mayankagarwalPosted on 2009-11-09 at 20:54:19ID: 25782508

Try with this
strSQL = "Select * from projects" & order_condn
instead of
strSQL = "Select * from [projects]"& order_condn

 

by: mayankagarwalPosted on 2009-11-09 at 20:55:16ID: 25782514

And please uncomment the response.write lines i.e.
REsponse.write(strSQL)
Response.end()
rsprojects.Open strSQL, adoCon  ' While Printing Hidden this line

 

by: meeran03Posted on 2009-11-09 at 21:00:11ID: 25782533

Have Uncomment these line n tried??
REsponse.write(strSQL)
Response.end()
'rsprojects.Open strSQL, adoCon  

 

by: mayankagarwalPosted on 2009-11-09 at 21:04:16ID: 25782548

Please give the result of uncommented lines.

 

by: kfranckPosted on 2009-11-09 at 21:30:07ID: 25782641

I made those changes, and you can see a response in the code when you click on Date, Completed or Priority. But the data is now missing.

See for yourselves at http://toledobladedata.com/digital/queue.asp.

I am including the code below.

<%
'Dimension variables
Dim adoCon 			'Holds the Database Connection Object
Dim rsMasterRolodex			'Holds the recordset for the records in the database
Dim strSQL			'Holds the SQL query for the database 
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection") 
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("digitalmedia.mdb") 
'Create an ADO recordset object
Set rsprojects = Server.CreateObject("ADODB.Recordset") 
'Initialise the strSQL variable with an SQL statement to query the database
%>  <!-- Server Tag Ends So now onwards Below Text is a HTML--> 
<a href="queue.asp?sort_order=adn">Date</a> |
<a href="queue.asp?sort_order=com"> Completed </a> |
<a href="queue.asp?sort_order=pri"> Priority </a>   
<% ' Again Server Tag started 
'Get The Query String Value  
sort_order="" 
sort_order = Request.QueryString("sort_order") 
sort_order = Replace(sort_order,"'","")  ' Avoid Error  
order_condn ="" 
If  sort_order = "adn" Then 
'-------------------- Space 
'               | 
order_condn  = " order by adn desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn 
elseif sort_order="com" then
order_condn  = " order by com desc"
elseif sort_order="pri" then 
order_condn  = " order by pri desc"
End if 
If isnull(sort_order) or sort_order = "" then 
strSQL = "SELECT projects.* FROM projects ORDER BY Completed;"  ' This just Loads By Completed ORder in ut queue.asp page 
else 
strSQL = "Select * from projects "& order_condn                   ' This Make sure to order accordingly to the click of the href . 
End if  
'Try to print your Sql Statement and check in database 
Response.write(strSQL)
Response.end()
rsprojects.Open strSQL, adoCon  ' While Printing Hidden this line
    
Dim counter
 counter=0
'Loop through the recordset
    Do While not rsprojects.EOF
    counter=counter+1
    'Write the HTML to display the current record in the recordset
     IF 0=(counter Mod 2) Then      
             Response.Write "<tr class='even'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      Else
            Response.Write "<tr class='odd'><td><a href=""Results.asp?ID="  & rsprojects("ID") & """>" & rsprojects.Fields("AdNumber") & "</a></td>"
      End If
    Response.Write "<td>" & rsprojects.Fields("Date") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:maroon;'>" & rsprojects.Fields("AccountNameNumber") & "</td>" 
    Response.Write "<td>" & rsprojects.Fields("Completed") & "</td>"
    Response.Write "<td>" & rsprojects.Fields("DigitalComponent") & "</td>"
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("Priority") & "</td>"     
    Response.Write "<td style='font-size:9pt;font-family:Arial; color:black;'>" & rsprojects.Fields("StartEndDate") & "</td>"
    Response.Write "</tr>"      
					
	'Move to the next record in the recordset
	 rsprojects.MoveNext
	Loop
%>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:

Select allOpen in new window

 

by: mayankagarwalPosted on 2009-11-09 at 21:34:06ID: 25782654

Now comments the response.write lines and try, it should work fine
i.e.
'Response.write(strSQL)
'Response.end()

 

by: kfranckPosted on 2009-11-09 at 21:40:43ID: 25782669

I get this error now:

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/digital/queue.asp, line 108

Line 108 is this darn line again:
rsprojects.Open strSQL, adoCon  ' While Printing Hidden this line

 

by: mayankagarwalPosted on 2009-11-09 at 21:44:07ID: 25782680

can you give me the "PROJECTS"  table structure

 

by: mayankagarwalPosted on 2009-11-09 at 21:45:20ID: 25782685

And please do one more thing:
Uncomment the respone.write line and comment the rresponse.end line then try and give me the output

 

by: meeran03Posted on 2009-11-09 at 21:50:36ID: 25782715

Comment this line while getting Output ....

Response.write(strSQL)
Response.end()


'-->>Coment'rsprojects.Open strSQL, adoCon  
'Too few parameters. Expected 1.

<%
'Dimension variables
Dim adoCon 			'Holds the Database Connection Object
Dim rsMasterRolodex			'Holds the recordset for the records in the database
Dim strSQL			'Holds the SQL query for the database 
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection") 
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("digitalmedia.mdb") 
'Create an ADO recordset object
Set rsprojects = Server.CreateObject("ADODB.Recordset") 
'Initialise the strSQL variable with an SQL statement to query the database
%>  <!-- Server Tag Ends So now onwards Below Text is a HTML--> 
<a href="queue.asp?sort_order=adn">Date</a> |
<a href="queue.asp?sort_order=com"> Completed </a> |
<a href="queue.asp?sort_order=pri"> Priority </a>   
<% ' Again Server Tag started 
'Get The Query String Value  
sort_order="" 
sort_order = Request.QueryString("sort_order") 
sort_order = Replace(sort_order,"'","")  ' Avoid Error  
order_condn ="" 
If  sort_order = "adn" Then 
'-------------------- Space 
'               | 
order_condn  = " order by adn desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn 
elseif sort_order="com" then
order_condn  = " order by com desc"
elseif sort_order="pri" then 
order_condn  = " order by pri desc"
End if 
If isnull(sort_order) or sort_order = "" then 
strSQL = "SELECT projects.* FROM projects ORDER BY Completed;"  ' This just Loads By Completed ORder in ut queue.asp page 
else 
strSQL = "Select * from projects "& order_condn                   ' This Make sure to order accordingly to the click of the href . 
End if  
'Try to print your Sql Statement and check in database 
Response.write(strSQL)
Response.end() 
Comment The Entire Below Region and now execute the Page . So that it avoid database activity .... 
'rsprojects.Open strSQL, adoCon   

'Dim counter
 'counter=0
'Loop through the recordset
  '  Do While not rsprojects.EOF
   ' counter=counter+1
    'Write the HTML to display the current record in the recordset
    ' IF 0=(counter Mod 2) Then      
     .....
......
...				
	'Move to the next record in the recordset
'	 rsprojects.MoveNext
'	Loop 
%>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:

Select allOpen in new window

 

by: meeran03Posted on 2009-11-09 at 21:51:58ID: 25782718

Uncomment till this Part only ..
Response.write(strSQL)
Response.end()

Comment The Entire Below Region and now execute the Page . So that it avoid database activity ....
'rsprojects.Open strSQL, adoCon  

'Dim counter
 'counter=0
'Loop through the recordset
  '  Do While not rsprojects.EOF
   ' counter=counter+1
    'Write the HTML to display the current record in the recordset
    ' IF 0=(counter Mod 2) Then      
     .....
......
...                        
      'Move to the next record in the recordset
'       rsprojects.MoveNext
'      Loop

 

by: kfranckPosted on 2009-11-09 at 21:54:48ID: 25782729

There are 22 fields in the "projects" table. All are text data type. Even though there are numbers in some of the fields, such as CPM, I use code to show that we are talking dollars and sense.

When I uncommented response.line,  I get the same error. Plus plus there is this code on the Date | Completed | Priority line Date |  Completed  |  Priority  SELECT projects.* FROM projects ORDER BY Completed;

Go to http://toledobladedata.com/digital/queue.asp to see.
kfranck

 

by: mayankagarwalPosted on 2009-11-09 at 22:00:39ID: 25782749

Does com is the actual field name n the table or is it completed.
If it is completed then please change the name of the fields in conditions
for e.g.
order_condn  = " order by completed desc"

 

by: meeran03Posted on 2009-11-09 at 22:01:25ID: 25782751

hi mate,

Do u have a column name as pri in ur table??

Select * from projects order by pri desc

pri represent Column name

if incase u dont have a pri column name

Replace

Select * from projects order by ur_prioritycolumnname desc




If  sort_order = "adn" Then 
'-------------------- Space 
'               | 
order_condn  = " order by ur_datecolumnname   desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn 
elseif sort_order="com" then
order_condn  = " order by ur_completedcolumnname  desc"
elseif sort_order="pri" then 
order_condn  = " order by ur_prioritycolumnname  desc"
End if 

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:

Select allOpen in new window

 

by: kfranckPosted on 2009-11-09 at 22:03:15ID: 25782762

Meeran03:

I commented the entire bottom section that your suggested. No data shows.

When I click on Date, I get this:
Date |  Completed  |  Priority  Select * from projects order by adn desc

When I click on Completed, I get this:
Date |  Completed  |  Priority  Select * from projects order by com desc

When I click on Priority, I get this:
Date |  Completed  |  Priority  Select * from projects order by pri desc

 

by: kfranckPosted on 2009-11-09 at 22:09:23ID: 25782791

The names of the fields for Date, Completed and Priority are Date, Completed and Priority.

So, should it be:

If  sort_order = "adn" Then
'-------------------- Space
'               |
order_condn  = " order by Date  desc" ' Dis Sort Descending order If U want Ascending Just Leave it to order by adn
elseif sort_order="com" then
order_condn  = " order by Completed  desc"
elseif sort_order="pri" then
order_condn  = " order by Priority  desc"
End if  

 

by: meeran03Posted on 2009-11-09 at 22:09:41ID: 25782793

Now comment The Response.end statement and uncomment the entire below region after that .

'Response.end

UNCOMMENT The Entire Below Region and now execute the Page .


rsprojects.Open strSQL, adoCon  

Dim counter
'counter=0
Loop through the recordset
  Do While not rsprojects.EOF
   counter=counter+1
    Write the HTML to display the current record in the recordset
     IF 0=(counter Mod 2) Then      
     .....
......
...                        
      Move to the next record in the recordset
       rsprojects.MoveNext
      Loop

 

by: meeran03Posted on 2009-11-09 at 22:10:27ID: 25782798

yes exactly ....

Now check ur code. mate...

 

by: mayankagarwalPosted on 2009-11-09 at 22:12:17ID: 25782805

YES THE ORDER CONDT SHOULD BE THIS.
PLEASE TRY WITH THIS IT WILL DEFINATELY WORK

 

by: kfranckPosted on 2009-11-09 at 22:20:30ID: 25782843

Folks:

We have a partial victory and I thank you!
Go to http://toledobladedata.com/digital/queue.asp and click on Date, Completed or Priority and it works.

Can we hide the "SELECT projects.* FROM projects ORDER BY" code?

kfranck

 

by: kfranckPosted on 2009-11-09 at 22:22:31ID: 25782846

I figured a way to hide that line, just comment
'Response.write(strSQL)

Will that work?

 

by: mayankagarwalPosted on 2009-11-09 at 22:24:38ID: 25782851

YES EXACTLY...
CONGRATS DUDE

 

by: kfranckPosted on 2009-11-09 at 22:25:29ID: 25782855

You guys are great! Thank you!!!

 

by: mayankagarwalPosted on 2009-11-09 at 22:27:08ID: 25782863

Please close this question

 

by: kfranckPosted on 2009-11-09 at 22:30:39ID: 31651560

Mayankagarwal and Meeran03 were terrific! I wish I could give them more points.

They stayed with me the entire project and never gave up. They both came up with great solutions and were extremely helplful.

They are truly experts. I thank and salute them!
kfranck

 

by: kfranckPosted on 2009-11-09 at 22:31:28ID: 25782879

It's closed. Thanks all again.

 

by: meeran03Posted on 2009-11-09 at 22:36:24ID: 25782899

thanks for ur appreciation .. :)
Good Luck ...

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...