Jeg får denne fejl : Subscript out of range: 'ArrayIndex'. og det undre mig for scriptet har virket længe men kommer nu med denne fejl. Tabel: Id Parentarticel 7 -1 8 11 9 509 10 11 11 -1 12 569
Kode: ParentArticle2 = 0 If "" & ID = "" Then ID = 1 If "" & ParentArticle = "" Or ParentArticle = "-1" Then ParentArticle = 1 ParentArticle2 = 1 end if
Dim aryParentIDs, aryParentTitles, aryParentURLs
Function PushItemFromStart( thisArray, element ) If Not isArray( thisArray ) Then Redim thisArray(0) Else ReDim Preserve thisArray(UBound(thisArray)+1) End If For Index = UBound(thisArray)-1 To 0 Step -1 thisArray(Index+1) = thisArray(Index) Next thisArray(0) = element End Function
Function findParentArticles( thisID )
' Identify ID in array ArrayIndex = -1 For Index = 0 To UBound( aryArticleID ) - 1 If CInt(aryArticleID( Index )) = CInt(thisID) Then ArrayIndex = Index Exit For End If Next
Glemte lige denne til af koden: ' Load bulletins into arrays Dim aryArticleID, aryParentArticle, aryArticleTitle, aryRedirectURL SQL = "SELECT ArticleID, Title, ParentArticle, RedirectURL, Position FROM Article WHERE OnlineStatus = 1 AND SUBSTRING(VisibleOn, 1, 1) = '1' AND DATEDIFF(d, DateOfCreation, GETDATE()) >= 0 ORDER BY Position" Set RS = Server.CreateObject("ADODB.Recordset") RS.Open SQL, conn, 3, 1 If Not RS.EOF Then ReDim aryArticleID( RS.RecordCount ) ReDim aryParentArticle( RS.RecordCount ) ReDim aryArticleTitle( RS.RecordCount ) ReDim aryRedirectURL( RS.RecordCount ) Index = 0 hasChilds = False Do While Not RS.EOF aryArticleID( Index ) = Trim( RS("ArticleID") ) aryParentArticle( Index ) = Trim( RS("ParentArticle") ) aryArticleTitle( Index ) = Trim( RS("Title") ) aryRedirectURL( Index ) = Trim( RS("RedirectURL") ) If CInt(aryParentArticle( Index )) = CInt( ID ) Then hasChilds = True Index = Index + 1 RS.MoveNext Loop Else Response.Write "Ingen artikler" End If RS.Close Set RS = Nothing
If hasChilds Then topID = ID Else topID = ParentArticle findParentArticles topID
så vidt jeg ved.... skal du lave en recordcount i sql'en, og den mangler du
SQL = "SELECT Count(*) as RecordCount, ArticleID, Title, ParentArticle, RedirectURL, Position FROM Article WHERE OnlineStatus = 1 AND SUBSTRING(VisibleOn, 1, 1) = '1' AND DATEDIFF(d, DateOfCreation, GETDATE()) >= 0 ORDER BY Position"
SQL = "SELECT Count(ArticleID) as RecordCount, ArticleID, Title, ParentArticle, RedirectURL, Position FROM Article WHERE OnlineStatus = 1 AND SUBSTRING(VisibleOn, 1, 1) = '1' AND DATEDIFF(d, DateOfCreation, GETDATE()) >= 0 ORDER BY Position"
Det er den samme fejl :o( Microsoft VBScript runtime error '800a0009'
Subscript out of range: 'ArrayIndex'
/menu.asp, line 35
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.