1
我只是繼承了一箇舊項目,以保持使用asp和vbs。在vbs中,它傳回單個對象,並且我需要將其作爲一個數組,我嘗試過的所有內容都會給我一個關鍵的異常。我將SQL讀取從單個記錄轉換爲數組,但是我無法將其傳回到我需要的主要對象,而我的項目中沒有人知道vbs。VBScript不通過類返回數組
Class LoadFileBS
Public Function getDocument(req, userProfile)
Dim dao
Set dao = new FileDAO 'define my class
Dim document
Set document = dao.retrieve(fileId) 'this was a single return that i'm trying to make into an array
If (checkAuthorization(document(1)) = true) Then 'tried making document an array and that didn't work for me. The (1) was a test to just try and get the array working in this class and not meant as finalized code.
Class FileDAO
Public Function Retrieve(fileId)
'Run the query and return the results
Set Retrieve = runDocumentQuery(fileId)
End Function
Private Function runDocumentQuery(fileId)
... 'making SQL call and it returns and i fill document with the info.
Dim document
Set document = new DocumentTO
Call document.setFileId(Trim(rs.fields(SQL_FILE_ID).value))
...
Set documents(UBound(documents)) = document
rs.MoveNext
If (NOT rs.Eof) Then
ReDim Preserve documents(UBound(documents) + 1)
End If
... 'now try and return
If (isObject(documents(1))) Then
Set runDocumentQuery = documents '<-- array with multiple records
Else
Set runDocumentQuery = nothing
End If
End Function
任何幫助或建議,將不勝感激。
感謝, 喬希
非常感謝您!這個伎倆。 – 2014-10-10 17:24:08