Array Help!

Results 1 to 2 of 2

Thread: Array Help!

  1. #1
    Join Date
    Dec 1969

    Default Array Help!

    Hello,<BR><BR>I am creating a dynamic spreadsheet and need to total each column in the<BR> Col1 Col2<BR> 5.00 2.00<BR> 3.00 7.00<BR> ---- ----<BR> 8.00 9.00<BR><BR>...and so on. In this example, the "5.00, 2.00 etc" come from a database using Do Until RS.EOF ....RS.MoveNext Loop so that each "row" is dynamic. How to add these up? Any help would be great!<BR><BR>Scott

  2. #2
    Join Date
    Dec 1969

    Default RE: Array Help!

    There&#039s a couple of ways-<BR><BR>a. Create another recordset with the following syntax:-<BR><BR>SELECT sum(col1) as val1,sum(col2) as val2<BR>FROM table<BR>WHERE condition;<BR><BR>and then tack them onto the end.<BR>This code is for Oracle but I&#039m sure there is something similar in SQL Server.<BR><BR>OR a better way<BR><BR>b.You create the number of variables that you have columns(in this case 2) and each time you write out a value you add it to the variable,i.e.<BR><BR>Dim var1,var2<BR><BR>While not objRec.eof<BR>Response.write objRec("col1")<BR>var1 = var1 + cint(objRec("col1"))<BR>Reponse.write objRec("col2)<BR>var2 = var2 + cint(objRec("col2"))<BR>objrec.movenext<BR>wend<BR >Response.write var1<BR>Response.write var2<BR><BR>Hope this helps

Posting Permissions

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