Re: User registration system: shows the minimum age among the users.

From: Val Mazur \(MVP\) (group51a_at_hotmail.com)
Date: 03/18/05


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 


Relevant Pages

  • Re: error no record
    ... : Dim UserName ... : 'Create the recordset object ... Set objRS = Nothing ... Set objConn = Nothing ...
    (microsoft.public.scripting.vbscript)
  • Re: error when trying to delete object
    ... Dim objConn ' ADO Recordset Object ... Set objConn = Server.CreateObject ... Set objRS = Server.CreateObject ... >: Dim strSQL ...
    (microsoft.public.inetserver.asp.db)
  • Re: Recordset not fully popoulated?
    ... soon as you open the recordset, ... There is no such thing, by the way, as ASP jumping to a line of code before ... > Set objConn = Server.CreateObject ... > Set objRS = Server.CreateObject ...
    (microsoft.public.inetserver.asp.general)
  • RE: Help with a function using recordsets
    ... where is the next part of the SQL statement. ... > Reading_Number and Age. ... > and create a recordset. ... > according to the rules I wrote in the function code. ...
    (microsoft.public.access.modulesdaovba)
  • RE: Help with a function using recordsets
    ... In my function code the Table is called tblAges, ... Reading_Number and Age. ... I then wish to evaluate the age values in each recordset and assign a P value ... I dont have much experiance with functions. ...
    (microsoft.public.access.modulesdaovba)