473,614 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display data on web page in ascending order

Joe
Hi,

I have an asp.net script that connects to MS Access database and displays
data in a table. For some reason I am do not know how to display data say in
ascending order of column1.

I have pasted below the script that I am using. I will appreciate if someone
can give me a clue as how to sort data in ascending or descending order when
displaying on the page.

Thanks,

Joe

<%@ page language="VB" debug="true" %>
<%@ Import Column1space="S ystem.Data" %>
<%@ Import Column1space="S ystem.Data.OleD b" %>
<script language="VB" runat="server">
sub Page_Load(sende r as Object, e as EventArgs)

Dim connString as String
Dim pathStr As String

pathStr = Left(Request.Ph ysicalApplicati onPath, 10)
connString = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;" _
& "DATA SOURCE=" & pathStr & "\databases\som edatabase.mdb"

Dim objConnection as OleDbConnection
objConnection = New OleDbConnection (connString)
objConnection.O pen()

Dim strSQL as String = "SELECT column1, column2 FROM sometable"

Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(st rSQL, objConnection)

Dim objDataReader as OleDbDataReader
objDataReader = objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)

'Set the table width.
DisplayTable.Wi dth = Unit.Percentage (100.0)
'Create a new row for adding a table heading
Dim tableHeading As TableRow = New TableRow()

'Create and add the cells that contain the Customer ID column heading
text.
Dim Column1IDHeadin g As TableHeaderCell = New TableHeaderCell ()
column1IDHeadin g.Text = "Column1"
column1IDHeadin g.backcolor =
System.Drawing. Color.FromColum n1(CType("#CCCC CC", String))
column1IDHeadin g.HorizontalAli gn = HorizontalAlign .Center
column1IDHeadin g.CssClass = "subsubTitl e"
tableHeading.Ce lls.Add(column1 IDHeading)

'Create and add the cells that contain the Contact Column1 column
heading text.
Dim companyHeading As TableHeaderCell = New TableHeaderCell ()
column2Heading. Text = “column2"
column2Heading. backcolor =
System.Drawing. Color.FromColum n2(CType("#CCCC CC", String))
column2Heading. HorizontalAlign = HorizontalAlign .Center
column2Heading. CssClass = "subsubTitl e"
tableHeading.Ce lls.Add(column2 Heading)

DisplayTable.Ro ws.Add(tableHea ding)

'Loop through the resultant data selection and add the data value
'for each respective column in the table.
While(objDataRe ader.Read())

Dim detailsRow As TableRow = New TableRow()
Dim column1Cell As TableCell = New TableCell()
column1Cell.Tex t = objDataReader(" column1").ToStr ing()
column1Cell.Css Class = "bodyText"
detailsRow.Cell s.Add(column1Ce ll)

Dim companyCell As TableCell = New TableCell()
companyCell.Tex t = objDataReader(" company").ToStr ing()
companyCell.Css Class = "bodyText"
detailsRow.Cell s.Add(companyCe ll)

'Add the new row to the table.
DisplayTable.Ro ws.Add(detailsR ow)

End While

objDataReader.C lose()
objConnection.C lose()

end sub

</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitl ed Document</title>
<link href="../styles/basic_cross_pla t.css" rel="stylesheet " type="text/css">
</head>
<body>
<a column1="top"></a>
<asp:Table id="DisplayTabl e" border="1" cellpadding="2" cellspacing="1"
runat="server"> </asp:Table>
<p><a href="#top" class="top">top </a></p>
</body>
</html>

Nov 18 '05 #1
2 3091
Try SELECT column1, column2 FROM sometable ORDER BY column1

"Joe" wrote:
Hi,

I have an asp.net script that connects to MS Access database and displays
data in a table. For some reason I am do not know how to display data say in
ascending order of column1.

I have pasted below the script that I am using. I will appreciate if someone
can give me a clue as how to sort data in ascending or descending order when
displaying on the page.

Thanks,

Joe

<%@ page language="VB" debug="true" %>
<%@ Import Column1space="S ystem.Data" %>
<%@ Import Column1space="S ystem.Data.OleD b" %>
<script language="VB" runat="server">
sub Page_Load(sende r as Object, e as EventArgs)

Dim connString as String
Dim pathStr As String

pathStr = Left(Request.Ph ysicalApplicati onPath, 10)
connString = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;" _
& "DATA SOURCE=" & pathStr & "\databases\som edatabase.mdb"

Dim objConnection as OleDbConnection
objConnection = New OleDbConnection (connString)
objConnection.O pen()

Dim strSQL as String = "SELECT column1, column2 FROM sometable"

Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(st rSQL, objConnection)

Dim objDataReader as OleDbDataReader
objDataReader = objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)

'Set the table width.
DisplayTable.Wi dth = Unit.Percentage (100.0)
'Create a new row for adding a table heading
Dim tableHeading As TableRow = New TableRow()

'Create and add the cells that contain the Customer ID column heading
text.
Dim Column1IDHeadin g As TableHeaderCell = New TableHeaderCell ()
column1IDHeadin g.Text = "Column1"
column1IDHeadin g.backcolor =
System.Drawing. Color.FromColum n1(CType("#CCCC CC", String))
column1IDHeadin g.HorizontalAli gn = HorizontalAlign .Center
column1IDHeadin g.CssClass = "subsubTitl e"
tableHeading.Ce lls.Add(column1 IDHeading)

'Create and add the cells that contain the Contact Column1 column
heading text.
Dim companyHeading As TableHeaderCell = New TableHeaderCell ()
column2Heading. Text = “column2"
column2Heading. backcolor =
System.Drawing. Color.FromColum n2(CType("#CCCC CC", String))
column2Heading. HorizontalAlign = HorizontalAlign .Center
column2Heading. CssClass = "subsubTitl e"
tableHeading.Ce lls.Add(column2 Heading)

DisplayTable.Ro ws.Add(tableHea ding)

'Loop through the resultant data selection and add the data value
'for each respective column in the table.
While(objDataRe ader.Read())

Dim detailsRow As TableRow = New TableRow()
Dim column1Cell As TableCell = New TableCell()
column1Cell.Tex t = objDataReader(" column1").ToStr ing()
column1Cell.Css Class = "bodyText"
detailsRow.Cell s.Add(column1Ce ll)

Dim companyCell As TableCell = New TableCell()
companyCell.Tex t = objDataReader(" company").ToStr ing()
companyCell.Css Class = "bodyText"
detailsRow.Cell s.Add(companyCe ll)

'Add the new row to the table.
DisplayTable.Ro ws.Add(detailsR ow)

End While

objDataReader.C lose()
objConnection.C lose()

end sub

</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitl ed Document</title>
<link href="../styles/basic_cross_pla t.css" rel="stylesheet " type="text/css">
</head>
<body>
<a column1="top"></a>
<asp:Table id="DisplayTabl e" border="1" cellpadding="2" cellspacing="1"
runat="server"> </asp:Table>
<p><a href="#top" class="top">top </a></p>
</body>
</html>

Nov 18 '05 #2
SELECT column1, column2 FROm table ORDER BY column1 DESC

Or ASC at end depending on direction you want :)

"Joe" wrote:
Hi,

I have an asp.net script that connects to MS Access database and displays
data in a table. For some reason I am do not know how to display data say in
ascending order of column1.

I have pasted below the script that I am using. I will appreciate if someone
can give me a clue as how to sort data in ascending or descending order when
displaying on the page.

Thanks,

Joe

<%@ page language="VB" debug="true" %>
<%@ Import Column1space="S ystem.Data" %>
<%@ Import Column1space="S ystem.Data.OleD b" %>
<script language="VB" runat="server">
sub Page_Load(sende r as Object, e as EventArgs)

Dim connString as String
Dim pathStr As String

pathStr = Left(Request.Ph ysicalApplicati onPath, 10)
connString = "PROVIDER=Micro soft.Jet.OLEDB. 4.0;" _
& "DATA SOURCE=" & pathStr & "\databases\som edatabase.mdb"

Dim objConnection as OleDbConnection
objConnection = New OleDbConnection (connString)
objConnection.O pen()

Dim strSQL as String = "SELECT column1, column2 FROM sometable"

Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(st rSQL, objConnection)

Dim objDataReader as OleDbDataReader
objDataReader = objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)

'Set the table width.
DisplayTable.Wi dth = Unit.Percentage (100.0)
'Create a new row for adding a table heading
Dim tableHeading As TableRow = New TableRow()

'Create and add the cells that contain the Customer ID column heading
text.
Dim Column1IDHeadin g As TableHeaderCell = New TableHeaderCell ()
column1IDHeadin g.Text = "Column1"
column1IDHeadin g.backcolor =
System.Drawing. Color.FromColum n1(CType("#CCCC CC", String))
column1IDHeadin g.HorizontalAli gn = HorizontalAlign .Center
column1IDHeadin g.CssClass = "subsubTitl e"
tableHeading.Ce lls.Add(column1 IDHeading)

'Create and add the cells that contain the Contact Column1 column
heading text.
Dim companyHeading As TableHeaderCell = New TableHeaderCell ()
column2Heading. Text = “column2"
column2Heading. backcolor =
System.Drawing. Color.FromColum n2(CType("#CCCC CC", String))
column2Heading. HorizontalAlign = HorizontalAlign .Center
column2Heading. CssClass = "subsubTitl e"
tableHeading.Ce lls.Add(column2 Heading)

DisplayTable.Ro ws.Add(tableHea ding)

'Loop through the resultant data selection and add the data value
'for each respective column in the table.
While(objDataRe ader.Read())

Dim detailsRow As TableRow = New TableRow()
Dim column1Cell As TableCell = New TableCell()
column1Cell.Tex t = objDataReader(" column1").ToStr ing()
column1Cell.Css Class = "bodyText"
detailsRow.Cell s.Add(column1Ce ll)

Dim companyCell As TableCell = New TableCell()
companyCell.Tex t = objDataReader(" company").ToStr ing()
companyCell.Css Class = "bodyText"
detailsRow.Cell s.Add(companyCe ll)

'Add the new row to the table.
DisplayTable.Ro ws.Add(detailsR ow)

End While

objDataReader.C lose()
objConnection.C lose()

end sub

</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitl ed Document</title>
<link href="../styles/basic_cross_pla t.css" rel="stylesheet " type="text/css">
</head>
<body>
<a column1="top"></a>
<asp:Table id="DisplayTabl e" border="1" cellpadding="2" cellspacing="1"
runat="server"> </asp:Table>
<p><a href="#top" class="top">top </a></p>
</body>
</html>

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
6871
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
4
2173
by: bobdedogh | last post by:
can anyone add live hyperlinks to the sortable table made by the code supplied by Machi, or know of a simple alternative bob Machi wrote Mar 10 1999, 8:00 am >>>>>>>>>>>>>> .... Hello Harjinder!
6
5344
by: sriram | last post by:
Hi, I have been seing a weird problem with db2look tool in db2 8.2 on Windows 2000 platform. When i spool the DDL using db2look, it spools the DDL in the ascending order of database objects Timestamp and not in the ascending order of db objects name. I need to spool the DDL in the ascending order db names. Can anyone
1
2189
by: deko | last post by:
I need to import dates from a linked table then export them out as text to an Excel spreadsheet. The problem is the dates need to be in ascending order when I dump them out to Excel - and there's no telling what order they are in in the linked table. I've tried this: INSERT INTO tblExcelData SELECT AS TestID, AS MeasDate, AS MeasTime
18
3198
by: Terry Holland | last post by:
I have an asp.net (1.1) application that connects to a SQL server 2000 db. I have a stored procedure in my db that out puts data in xml format. What I need to be able to do is display that xml that I retrieve from my stored proc and display it in a web page formatted as I want. I have managed to get my xml to display as I wish if I manually run my stored proc in QA and copy the xml into notepad and save it as Test.xml. I reference my xsl...
5
6681
KevinADC
by: KevinADC | last post by:
Introduction This discussion of the sort function is targeted at beginners to perl coding. More experienced perl coders will find nothing new or useful. Sorting lists or arrays is a very common requirement of programs. If you don't know the difference between a list and array don't worry about it. A list is just an array without a name. They both can hold the same type of data: scalars or strings. I will use the terms "list" and "array" to...
1
7181
KevinADC
by: KevinADC | last post by:
Introduction In part one we discussed the default sort function. In part two we will discuss more advanced techniques you can use to sort data. Some of the techniques might introduce unfamiliar methods or syntax to a less experienced perl coder. I will post links to online resources you can read if necessary. Experienced perl coders might find nothing new or useful contained in this article. Short Review In part one I showed you some...
3
7325
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article uses unfamiliar terms and syntax. Intermediate and advanced Perl coders should find this article useful. The object of the article is to inform the reader, it is not about how to code Perl or how to write good Perl code, but to teach the Schwartzian...
0
1716
by: selvamariappan | last post by:
Hi all , I am using Crystal Report in asp.net , I want to display the year in ascending order , Eg: In my table The Field value is in the form of (YYYY) I Want to display the records based on that year,
0
8197
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5548
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2573
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.