你如何从GetRows()获得列数?

时间:2018-01-22 04:42:58

标签: sql vbscript asp-classic ado

如何获取SQL数组?我永远不会看到“noOfColumns3”行。 SQL正在运行。

Function getSubmittalNotes(submitId)
    Dim note_list, note_conn
    Dim test
    Set note_conn = Server.CreateObject("ADODB.Connection")
    note_conn.Open Application("DSN")
    Set note_list = Server.CreateObject("ADODB.Recordset")
    note_list.CursorLocation = 3
    note_list.Open "SELECT [ID], [SubmitID], [UserID], [EnteredTime], [Note] FROM [dbo].[SubmittalNotesHistory] where [SubmitID] = " & submitId, note_conn, 1, 3
    'set notes = note_list.GetRows
    If note_list.RecordCount = 0 Then
        test = ""
        Response.Write "noOfColumns123 : <BR>"
    Else
        note_list.MoveFirst
        test = note_list.GetRows
        Response.Write "noOfColumns3 : " & test & "<BR>"
    End If
    note_list.Close
    Set note_list = Nothing
    note_conn.Close
    Set note_conn = Nothing
    Response.Write "getSubmittalNotes : " & test & " <BR>"
    getSubmittalNotes = test
End Function

1 个答案:

答案 0 :(得分:0)

尝试更改

test = note_list.GetRows
Response.Write "noOfColumns3 : " & test & "<BR>"

test = note_list.GetRows
Response.Write "noOfColumns3 : " & UBound( test ) & "<BR>"

有关UBound()函数的更多信息:https://www.w3schools.com/asp/func_ubound.asp