【问题标题】:How do you get number of columns from GetRows()?如何从 GetRows() 获取列数?
【发布时间】:2018-01-22 04:42:57
【问题描述】:

如何只取一个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

【问题讨论】:

标签: sql vbscript asp-classic ado


【解决方案1】:

尝试改变

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

【讨论】:

  • @Lankymart:你真的最近访问过你链接的网站吗?因为它说 w3schools 现在很好。
  • @Lankymart 恐怕玛哈是正确的。虽然 w3schools 并不完美,也不是大师写的,但它现在的内容还不错,没有真正的缺陷。这是完全有效且合法的链接。
  • @lankymart:在你嘴上说不使用 w3schools 之前(我看到评论已被删除,大概是你删除的),你为什么不实际阅读内容?如果它有什么问题,请说明它是什么。与否决我的答案相同(无论是谁这样做,大概是你),解释它有什么问题。
  • Ubound(test) + 1 的列数,我想?
猜你喜欢
  • 2014-01-24
  • 2021-02-23
  • 2014-05-22
  • 2011-02-06
  • 1970-01-01
  • 1970-01-01
  • 2020-05-18
  • 2018-05-04
  • 1970-01-01
相关资源
最近更新 更多