Re: User registration system: shows the minimum age among the users.
From: Val Mazur \(MVP\) (group51a_at_hotmail.com)
Date: 03/18/05
- Next message: Val Mazur \(MVP\): "Re: How to download ole objects(MS Access) from ASP?"
- Previous message: Val Mazur \(MVP\): "Re: monitoring database"
- In reply to: Ben: "User registration system: shows the minimum age among the users."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Mar 2005 21:00:16 -0500
Hi Ben,
I believe you need to create alias for your values in a SQL statement,
otherwise field name in a recordset will be changed
SELECT MIN(age) AS age FROM user
-- Val Mazur Microsoft MVP http://xport.mvps.org "Ben" <tungben@gmail.com> wrote in message news:2be0ff02.0503161847.3f3efaaf@posting.google.com... >I can't shows the minimum age among the users. > > > > > <%@ Language=VBScript %> > <% Option Explicit %> > > <% > '------------------------------------------------- > '1. Open up a connection to our Access database > '------------------------------------------------- > Dim objConn > Set objConn = Server.CreateObject("ADODB.Connection") > objConn.ConnectionString ="DRIVER={Microsoft Access Driver > (*.mdb)};DBQ=C:\temp\open.mdb" > objConn.Open > > '------------------------------------------------- > '2. Create a recordset object instance and retrieve the information > from the User table > '------------------------------------------------- > Dim objRS > Set objRs = objConn.Execute("SELECT * FROM user") > > '----find min age and avg age------ > Dim objMin > Set objMin = objconn.Execute("SELECT MIN(age) FROM user") > Response.Write objMIN("age") > > > > '------------------------------------------------- > '3. Display the contents of the user table > '------------------------------------------------- > Do While Not objRS.EOF > Response.Write ("Name=") > Response.Write objRS("name") & ", " > Response.Write ("Age=") > Response.Write objRS("age") & ", " > Response.Write ("Sex=") > Response.Write objRS("sex") & ", " > Response.Write ("Id=") > Response.Write objRS("id") > Response.Write "<BR>" > objRS.MoveNext > Loop > Response.Write "=====================================================" > > > '------------------------------------------------- > '4. Clean up our ADO objects > '------------------------------------------------- > objRS.Close > objConn.Close > Set objConn = Nothing > Set objRS = Nothing > %> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Our user database as following(open.dbm) > > Name Age Sex id > AAA 30 M AAA30 > BBB 20 M BBB20 > CCC 10 M CCC10 > DDD 20 F DDD20 > EEE 30 F EEE30
- Next message: Val Mazur \(MVP\): "Re: How to download ole objects(MS Access) from ASP?"
- Previous message: Val Mazur \(MVP\): "Re: monitoring database"
- In reply to: Ben: "User registration system: shows the minimum age among the users."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|