Sql server 2008 我是否在VBscript中正确使用DO WHILE NOT和EOF

Sql server 2008 我是否在VBscript中正确使用DO WHILE NOT和EOF,sql-server-2008,asp-classic,vbscript,Sql Server 2008,Asp Classic,Vbscript,最后,管理员为我配置了IIS。下面列出了错误消息。 设置SQLStream=CreateObjectADODB.Stream 设置SQLConnection=CreateObjectADODB.Connection Set SQLCommand=CreateObjectADODB.Command Set SQLRecordSet=CreateObjectADODB.RecordSet SQLConnection.openprovider=sqloledb;SERVER=SQLPROD;数据库=M

最后,管理员为我配置了IIS。下面列出了错误消息。 设置SQLStream=CreateObjectADODB.Stream 设置SQLConnection=CreateObjectADODB.Connection Set SQLCommand=CreateObjectADODB.Command Set SQLRecordSet=CreateObjectADODB.RecordSet SQLConnection.openprovider=sqloledb;SERVER=SQLPROD;数据库=MyDataBase;UID=我的用户名;PWDMyPassword

    'Response.Write("Connection Status: " & SQLConnection.State) & vbnewline
    'Response.Write("Connection Provider: " & SQLConnection.Provider) & vbnewline
    'Response.Write("Version: " & SQLConnection.Version) & vbnewline

    SQLCommand.ActiveConnection = SQLConnection
    SQLCommand.CommandText = "SELECT Seminars.Year, Seminars.SeminarID, Seminars.Theme, Seminar_Week.First, Seminar_Week.Last, Seminar_Week.WeekID, Seminar_Week.Date, Seminar_Week.Affiliation FROM Seminars CROSS JOIN Seminar_Week"
    'Response.Write("SQL Command Passed in: " & SQLCommand.CommandText)

    Set adoRec = SQLCommand.Execute()
        file1 = "./seminars/" & seminar_type & "/" & seminar_year & "/" & adoRec("Date") & "-" & adoRec("Year") & "_" & adoRec("Last") & ".pdf"
        file2 = "./seminars/" & seminar_type & "/" & seminar_year & "/" & adoRec("Date") & "-" & seminar_year & "_" & adoRec("Last") & "(handouts).pdf"
        file3 = "./seminars/" & seminar_type & "/" & seminar_year & "/" & adoRec("Date") & "-" & seminar_year & "_" & adoRec("Last") & "_Flyer.pdf"
    Set fso = CreateObject("scripting.filesystemobject")
        Response.Write("<p style=" & "margin-left:10px;" & "><img src=" & "./img/right_arrowblue.png" & " alt=" & "Expand/Collapse" & " id=" & "arrow_" & adoRec("Week") & " /><strong>[" & adoRec("Date") & "]</strong> " & "<a href=" & "javascript:toggle('seminar_" & adoRec("Week") &"')"">"&aroRec("First") & adoRec("Last") & ", " & adoRec("Affiliation") & "</a></p>")
最后一行代码导致此错误

ADODB.记录集错误“800a0cc1”

在与请求的名称或序号对应的集合中找不到项

文件路径,第244行

第244行是最后一行代码,应该在网页上写下关于每个研讨会的一些信息

我很确定,此时我指向了一个不正确的文件路径,因为在所有不同的字符串中,我有一个额外的空间

我现在的问题是,一开始的那些,也就是在

"<p style=" & "margin-left:10px;" & "><img src=" & "./img/right_arrowblue.png"
这是造成麻烦的原因

我也不熟悉使用展开/折叠,所以如果有人能告诉我更多关于这方面的信息。我正在尝试修复其他人的代码,因此我有点落后于8球。

是否缺少循环块末尾的循环关键字

检查此处的语法:


将上述代码放在Loop关键字之前,以避免无限循环。

解决方案的一小步:

您的SQL

"SELECT * FROM Seminars WHERE [SeminarID] = 5 ORDER BY DESC"
这绝对是错误的:ORDER BY至少需要一个列名:ORDER BY[Seminand]DESC

如果这不能解决你所有的问题,我们将不得不考虑一个循序渐进的方法

如果您有错误,请告诉我们错误号、说明、行。这就是我的意思,当我要求你们出版它们的时候。如果在处理来自IIS的URL时出现错误,那么您必须编写一些命令行脚本,以确保与数据库相关的代码完全正确

从experiments.vbs开始:

  Dim sCS : sCS     = !your connection string!
  Dim oCN : Set oCN = CreateObject("ADODB.Connection")
  oCN.Open sCS
  WScript.Echo "CN open:", oCN.State

  Dim sSQL : sSQL    = !your SQL statement!
  Dim oRS  : Set oRS = oCN.Execute(sSQL)
  WScript.Echo "RS EOF:", CStr(oRS.EOF)
  WScript.Echo "Frs Col:", oRS.Fields(0).Name, oRS.Fields(0).Type

  Dim i : i = 0
  Do Until oRS.EOF
     WScript.Echo i, oRS.Fields(0).Value
     i = i + 1
     oRS.MoveNext
  Loop
  oCN.Close
并在命令窗口DOS框中运行:cscript experiments.vbs。这将为您提供一些行,如:

CN open: 1
RS EOF: False
Frs Col: Id 3
0 ...
1 ...
2 ...
或一条集中/可发布的错误消息,如:

... .vbs(2465, 14) Microsoft OLE DB Provider for SQL Server: Falsche Syntax in der Nä
he des 'DESC'-Schlüsselworts.
DESC附近的语法错误,在我尝试该语句时得到

"SELECT * FROM Alpha ORDER BY DESC"

如果打算将其用作VBScript,则在分配.Execute的返回值时不使用Set是一个致命错误;如果代码是VB.NET,那么请更正标记。Execute前面的设置导致页面出错,因此我将其删除,然后重新开始正常工作。我应该把它加回去吗?如果我将其重新添加并再次开始接收错误,会是什么原因?假设您使用VBScript编写代码,则必须使用该集才能从.Execute获取记录集。如果使用集合导致错误,请发布它们。下一次恢复活动时是否有错误?是,禁用它,并发布错误。如果您未使用VBScript,则所有赌注均已取消。是,这是VBScript。也许我做的记录集是错误的,我现在已经将它添加到上面的代码中,这样您也可以看到,下一步恢复时没有错误,我将如何实现发布错误?抱歉,我对VBscriptfirst非常陌生,如果可能的话,在IIS集中,这样您就可以得到实际的错误。这将使您更好地了解错误是什么以及错误发生在哪一行。其次,需要为连接指定一个连接字符串。第三,您需要在.execute循环关键字出现之前打开连接。我已经编辑了这篇文章,现在包含了它。插入了代码,但仍然收到错误。现在说在处理URL时出现了一个错误。感谢上面的修复,尽管无限循环从来都不是好的,我将列名添加到ORDER BY,但我仍然收到错误。CN打开:1 RS EOF:False,Frs Col:Year 3,0 2011,1 2010,2 2011,…,6 null。正确读取数据库
"SELECT * FROM Alpha ORDER BY DESC"