当我执行第二个ASP对象时,我的页面死了

时间:2015-03-18 13:57:56

标签: asp.net vb.net

我不太了解ASP,这是我的代码:

 <%
dim objCmd, objRS1, objRS2, strDate1, strDate2, strName, strStyle, datDate, strLastGroup, datNow
set objCmd = Server.CreateObject("ADODB.Command")
Set objRS1 = Server.CreateObject("ADODB.Recordset")
Set objRS2 = Server.CreateObject("ADODB.Recordset")
set objCmd.ActiveConnection = objConn

objCmd.CommandText = "Select Site_Pages.Filename, HeadingName, MatrixName, Site_Matrices.MatrixID, TurnaroundOverride, TurnaroundName, MAX(Turnaround) AS AutoTurnaround, TurnaroundGroup FROM Site_Headings, Site_Pages, Site_Matrices, Site_Items, Site_Items_Prices, Items WHERE Site_Headings.HeadingID = Site_Pages.HeadingID AND Site_Pages.ProdPageID = Site_Matrices.ProdPageID AND Site_Matrices.MatrixID = Site_Items.MatrixID AND Site_Items.ItemID = Site_Items_Prices.ItemID AND Site_Items_Prices.PriceID = Items.PriceID AND SiteID = 0 AND TurnaroundPage = 1 GROUP BY HeadingName, MatrixName, TurnaroundOverride, TurnaroundName, Site_Pages.Filename, TurnaroundGroup, TurnaroundSortOrder, Site_Matrices.MatrixID ORDER BY TurnaroundGroup, TurnaroundSortOrder, HeadingName, MatrixName, TurnaroundName"
set objRS1 = objCmd.Execute

if not objRS1.eof then
    Call NewTable(objRS1("TurnaroundGroup"))
    strLastGroup = objRS1("TurnaroundGroup")
end if

do until objRS1.eof

    if strLastGroup <> objRS1("TurnaroundGroup") then
        Call EndTable()
        Call NewTable(objRS1("TurnaroundGroup"))
    end if
    strLastGroup = objRS1("TurnaroundGroup")

    'decide todays date for checking dated turnaround overrides
    datNow = dateadd("h", GetSetting("TimeOffset"), now())
    'if before 7am, knock off a day
    if hour(datnow) < 7 then datnow = dateadd("d", -1, datnow)


    objCmd.CommandText = "SELECT Turnaround FROM DatedTurnarounds WHERE MatrixID = " & CLng(objRS1("MatrixID")) & " AND TDate = '" & Year(datNow) & PadWithZeros(Month(datNow)) & PadWithZeros(Day(datNow)) & " 00:00'"

    set objRS2 = objCmd.Execute


    if objRS1("TurnaroundOverride") = 0 OR IsNull(objRS1("TurnaroundOverride")) then
        if objRS2.eof then  'use automatic (3-last)
            datDate = AddDays(objRS1("AutoTurnaround")-1)
        else                'use dated turnaround override (2-second)
            datDate = AddDays(objRS2("Turnaround")-1)
        end if
    else                    'use matrix overrride (1-first - overrides all)
        datDate = AddDays(objRS1("TurnaroundOverride")-1)
    end if

    strDate1 = Left(WeekDayName(DatePart("w", datDate)), 3) & " " & DateSuffix(DatePart("d", datDate)) & " of " & MonthName(DatePart("m", datDate))

    if objRS1("TurnaroundOverride") = 0 OR IsNull(objRS1("TurnaroundOverride")) then
        if objRS2.eof then  'use automatic (3-last)
            datDate = AddDays(objRS1("AutoTurnaround"))
        else                'use dated turnaround override (2-second)
            datDate = AddDays(objRS2("Turnaround"))
        end if
    else                    'use matrix overrride (1-first - overrides all)
        datDate = AddDays(objRS1("TurnaroundOverride"))
    end if
    objRS2.close



    strDate2 = Left(WeekDayName(DatePart("w", datDate)), 3) & " " & DateSuffix(DatePart("d", datDate)) & " of " & MonthName(DatePart("m", datDate))

    if objRS1("TurnaroundName") = "" OR IsNull(objRS1("TurnaroundName")) then
        if objRS1("MatrixName") = "" OR IsNull(objRS1("MatrixName")) then
            strName = objRS1("HeadingName")
        else
            strName = objRS1("MatrixName")
        end if
    else
        strName = objRS1("TurnaroundName")
    end if

    if strStyle = "PriceMatrixRow1" then
        strStyle = "PriceMatrixRow2"
    else
        strStyle = "PriceMatrixRow1"
    end if
%>

我认为这个问题应该在这里

objCmd.CommandText = "SELECT Turnaround FROM DatedTurnarounds WHERE MatrixID = " & CLng(objRS1("MatrixID")) & " AND TDate = '" & Year(datNow) & PadWithZeros(Month(datNow)) & PadWithZeros(Day(datNow)) & " 00:00'"

set objRS2 = objCmd.Execute

我不确定我是否可以在对象中执行另一个对象 非常感谢任何帮助。

0 个答案:

没有答案