Assigning Values To An Array Doesn’t Work In Included File In ASP (VBScript)

ISSUE
I have run into a lot of little issues with ASP that I can’t seem to find documentation on. I admit, I’m not 100% on .NET but I do know VBScript. The problem I ran into was with a configuration file I had set up so I can use constant variables throughout the website. I declare all my variables in my directory includes in a file named config.inc.aspx .

When I went to set up an array that I want to use throughout the website, cfg_media_types_array, declaration goes fine but assigning the array values throws an error.

Line 22:
Line 23: Dim cfg_media_types_array(4)
Line 24: cfg_media_types_array(1) = “CD”
Line 25: cfg_media_types_array(2) = “Floppy”
Line 26: cfg_media_types_array(3) = “DVD”

The error I receive is the Compilation Error BC30188: Declaration expected.

I’ve also tried different ways of implementing the cfg_media_types_array variable, whatever I could find on the internet. None of which would successfully compile.

Furthermore, I tried to assign the values of the array in a different scope (in different <% %> brackets). That wouldn’t work either.

WORK AROUND
Since strings have no problem being declared and assigned in my config file, I simply declared a strong with coma separated values.

Dim cfg_media_types_array As String = “CD,Floppy,DVD,Other”

When I need to use the string, I simply do a split.

' split the configuration media types string up to an array
Dim a = split(cfg_media_types_array, ",")
Dim b
' loop through the array
For Each b in a
          Response.Write("<option value=""" & b & """")
          If b = sw_media_type Then
                    Response.Write(" selected=""selected""")
          End If

          Response.Write(">" & b & "</option>" & VbCrLf)
Next

Get The Count And Details From Multiple Tables Using Join

ISSUE
You need to query data as well as a count from another table. You don’t want to use two queries to accomplish what one could do.

FIX
Use a right outer join for your data table to your count table.

EXAMPLE
I have two tables, one Hardware which has attributes of hw_type, hw_equip_name, hw_manufacturer, and hw_decal_num. I have another table, HardwareUpdate, which keeps a hw_decal_num (foriegn key to Hardware) and an update_id (foriegn key to Update) to keep track of updates done on hardware.

I want to get the details of all the hardware as well as how many updates were performed on that specific piece of hardware.

My query:

SELECT h.hw_decal_num, h.hw_type, h.hw_equip_name, COUNT(hwu.hwu_id) AS hw_update_count
FROM hardwareupdate hwu RIGHT OUTER JOIN hardware h ON hwu.hw_decal_num = h.hw_decal_num
GROUP BY h.hw_decal_num, h.hw_type, h.hw_equip_name
ORDER BY h.hw_equip_name

Also to note, all the attributes you are using from the table you are getting data from (in our example it’s Hardware) should be listed in the GROUP BY clause.