Home-->
Articles -->
Site Tools
To sort out the data of a table with ASP Afficher

Post By drs2007 on 2008-9-26 15:43:40 [Reads:277]
To sort out the data of a table with ASP Afficher in bulk
The registrations of a table in one page present ASP often a limited interest. The things become distinctly more interesting when he/it is question to do a previous sorting to display the registrations answering precise criterias only.
We are going to approach a stage fundamental of ASP: to sort out the data contained in a table in order to select some registrations only.
Let's take our Access basis previously named mabase.mdb. In this one, let's reopen the table titled table1. She/it always contains the following fields: Name of the field Parameters Id Type NuméroAuto Name Marks Text, Length 50 bus.
First name Marks Text, Length 30 bus.
Age Numeric Type (whole long)
The corresponding DSN to the mabase.mbd basis is always called mabase.
Let's create some registrations:
MARTIN Paul, 37 years LECLERC Yves, 56 years DURAND Jacques, 31 years RAYMOND Yvette, 68 years,
We are going to try to display the people whose age is lower than 50 years only. And we are going to classify the corresponding people by alphabetic order of the name.
<% OBJdbConnection set = Server.CreateObject ("ADODB.Connection") OBJdbConnection.Open SQL "mabase" = "SELECT * FROM table1 Aged where < 50 order by Name" Set rs = OBJdbConnection.Execute(SQL)% >
This script serves to establish a connection with the DSN created previously.
Then, inside the beacon < LEOTARD > of the page, we are going to display the on line data, under the shape,: Name, First name, Age. This last #118alue being numeric, we will make it follow of the word "years" for a better legibility.
<% do while rs.EOF not% > <% = rs ("Name")% >, <% = rs ("First name")% >, <% = rs ("Age")% > years < br > <% rs.movenext loop% > <% rs.close set rs = nothing% >
We note the following result: