Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Help with Access Database connection


Message #1 by "Chris" <chrscote@9...> on Sat, 15 Sep 2001 12:43:25 -0400
    I am having a problem with an ASP page I'm working on.  I have an 

Access database to keep stats for baseball.  I am trying to have my ASP 

page total each player's Stats in each category (AB, R, Hits, etc.) and 

print them out.

   I'd like to have a function that goes through each field in the 

database and find the sum of that field and place the sums in a

recordset, but I don't want to have to hard-code all of the field names 

since there are about 20 of them.

   Also, is there a way to have this separate function use the database 

connection from the main program?  I am using a DNS connection, as

opposed to a DNS-less one.



If anyone can help me, it would be appreciated.



Chris Cote
Message #2 by "Zee Computer Consulting" <zee@t...> on Sun, 16 Sep 2001 16:47:00 -0700
''' Stat database table and Total database table

''' must have same structure



''' Open the connections and recordsets

"' here



''' Try improving on this

''' by using StatField.Type



' Dimension the array for field totals and zeroize

FIELDMAX  = 100

dim TotalCount()

redim TotalCount( FIELDMAX )

FOR t = 0 TO FIELDMAX

    TotalCount(t) = 0

NEXT



' Loop through the Stat table recordset

WHILE NOT StatRecordset.EOF



    ' Zeroize the field counter

    fc = 0



    ' Loop through the fields

    FOR EACH StatField in StatRecordset.Fields

        fc = fc + 1

        ' Check for numbers

        IF IsNumeric( StatField.Value) THEN

            ' Add to field total

            TotalCount( fc ) = StatField.Value

        END IF

    NEXT



    ' Move to next record

    StatRecordset.MoveNext



LOOP

' End of record loop



' Add a mew blank record to the total database

TotalRecordet.AddNew



' Loop through the stat fields collection and put sums in total recordset

FOR EACH StatField in StatRecordset.Fields

    IF TotalCount(c) <> 0 THEN

        TotalRecordset.Fields( StatField.Name ) = TotalCount(fc)

    END IF

NEXT



' Save the changes

TotalRecordset.Update



''' Close the databases

'''











----- Original Message ----- 

From: "Chris" <chrscote@9...>

To: "Access ASP" <access_asp@p...>

Sent: Saturday, September 15, 2001 9:43 AM

Subject: [access_asp] Help with Access Database connection





    I am having a problem with an ASP page I'm working on.  I have an 

Access database to keep stats for baseball.  I am trying to have my ASP 

page total each player's Stats in each category (AB, R, Hits, etc.) and 

print them out.

   I'd like to have a function that goes through each field in the 

database and find the sum of that field and place the sums in a

recordset, but I don't want to have to hard-code all of the field names 

since there are about 20 of them.

   Also, is there a way to have this separate function use the database 

connection from the main program?  I am using a DNS connection, as

opposed to a DNS-less one.



If anyone can help me, it would be appreciated.



Chris Cote










  Return to Index