Spudhead
02-25-2003, 04:02 PM
Hi,
I need to make the following function, that will sit in a 'local functions' include file, that I can use to return me an array of regions from a database.
I've got it pulling the data out ok, but I'm a little unclear on how to pass an array to a function for it to populate and return.
I currently get a "Subscript out of range" error, which I guess it telling me I'm trying to treat something as an array that isn't an array?
Function GetRegionsList()
dim buf, n
buf=Array()
n=0
Qstr="SELECT * FROM [" & application("tblSKU") & "] WHERE [U_Product_Type] = " & AO_Region
if AO_OnWebSale <> "" then
Qstr = Qstr & " And [U_Web_Sales_Status] = " & AO_OnWebSale
end if
Qstr = Qstr & " Order By DESCRIPTION"
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open ConnectString
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open qstr,objConn, 1
do while not rs.eof
buf(n) =rs("SKU_ID")
n=n+1
rs.movenext
loop
rs.close
set rs=nothing
objConn.close
set objConn=Nothing
GetRegionsList=buf
End function
I need to make the following function, that will sit in a 'local functions' include file, that I can use to return me an array of regions from a database.
I've got it pulling the data out ok, but I'm a little unclear on how to pass an array to a function for it to populate and return.
I currently get a "Subscript out of range" error, which I guess it telling me I'm trying to treat something as an array that isn't an array?
Function GetRegionsList()
dim buf, n
buf=Array()
n=0
Qstr="SELECT * FROM [" & application("tblSKU") & "] WHERE [U_Product_Type] = " & AO_Region
if AO_OnWebSale <> "" then
Qstr = Qstr & " And [U_Web_Sales_Status] = " & AO_OnWebSale
end if
Qstr = Qstr & " Order By DESCRIPTION"
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open ConnectString
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open qstr,objConn, 1
do while not rs.eof
buf(n) =rs("SKU_ID")
n=n+1
rs.movenext
loop
rs.close
set rs=nothing
objConn.close
set objConn=Nothing
GetRegionsList=buf
End function