반응형
In classic asp, it is impossible to initiate an array without specifying the size of the array. So, it has to resize array dynamically. Specially, it couldn’t expect how many size need to initiate array when you get the data from db or file.
1. Use Preserve keyword
Dim arr_od_no()
ReDim arr_od_no(-1) Do While objRs_01.eof = false
ReDim Preserve arr_od_no(UBound(arr_od_no) + 1)
arr_od_no(UBound(arr_od_no)) = objRs_01("od_no")
objRs_01.MoveNext
Loop
For i = 0 to UBound(arr_od_no)
Response.Write "(" & i & ") Value " & arr_od_no(i) & "<br>"
Next
2. Use Split Function
Dim strAllID
strAllID = ""
Do Until objRS.EOF
If Len(strAllID)>0 Then
strAllID = strAllID & ","
End If
strAllID = strAllID & objRS("ID")
objRS.MoveNext
Loop
objRS.Close
Dim arrIDs
arrIDs = Split(strAllID, ",")
반응형
'PROGRAMING > CLASSIC ASP' 카테고리의 다른 글
[ASP] ASP Encoding 설정 (0) | 2011.06.09 |
---|---|
[ASP] 반올림 (0) | 2011.05.26 |
[ASP] Split를 이용한 2차원배열 (0) | 2011.04.12 |
[ASP] ASP + MySQL Connection (0) | 2011.04.05 |