Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Location
    Houston, TX
    Posts
    34

    Unanswered: build array from database

    I need to insert two values from a table in a database into an array. I know nothing about arrays!

    I am using a script that builds a chart that uses an array which is why I need this.

    The Array in the Chart script looks like this:
    ShowChart Array(835, 636, 809, 724), Array("7/12/2003", "7/26/2003", "7/29/2003", "8/1/2003"), "Photo Totals", "Locations", "Photos"

    I added the numbers and dates as an example of the data being pulled from the database. Basically I am pulling the number of photos taken per date.

    I can select the data using this script below but I don't know how to add the values to the Array.

    Set RS1 = conn.Execute("SELECT DISTINCT photo_date FROM tbl_photos WHERE tbl_photos.event_id = '"&event_id&"' ")

    Do While Not RS1.EOF

    photo_date = RS1("photo_date")

    sql_1 = "SELECT COUNT(Code2) AS total_photos_taken FROM(SELECT event_id, code2 FROM tbl_photos WHERE event_id = '"&event_id&"' and photo_date = '"&photo_date&"') DERIVEDTBL"

    Set RS = Conn.Execute(sql_1)
    total_photos_taken = RS(0)


    RS1.MoveNext
    Loop

    Can someone help me add the values to the Array?

  2. #2
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Here's an excerpt of filling an array from a sample page regarding my own barchart (www.bullschmidt.com/barchart.asp):

    Dim aChartData(2, 3) ' Max fld num - 1, max row num minus 1, note arrays start at 0.

    ' Fill aChartData.
    ' (Row 1.)
    aChartData(0, 0) = 5123.23
    aChartData(1, 0) = 3906.54
    aChartData(2, 0) = 3578.97
    ' (Row 2.)
    aChartData(0, 1) = 5582.23
    aChartData(1, 1) = 4679.10
    aChartData(2, 1) = 3035.00
    ' (Row 3.)
    aChartData(0, 2) = 7027.02
    aChartData(1, 2) = 5756.55
    aChartData(2, 2) = 3921.45
    ' (Row 4.)
    aChartData(0, 3) = 6652.78
    aChartData(1, 3) = 6756.43
    aChartData(2, 3) = 4034.76
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •