Avatar billede allan-k Nybegynder
12. marts 2006 - 18:47 Der er 12 kommentarer

Subscript out of range: 'ArrayIndex'

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

PushItemFromStart aryParentIDs, thisID
*fejlen*PushItemFromStart aryParentTitles, aryArticleTitle(ArrayIndex)
PushItemFromStart aryParentURLs, aryRedirectURL(ArrayIndex)

If "" & aryParentArticle(ArrayIndex) <> "-1" Then                findParentArticles aryParentArticle(ArrayIndex)

End Function

Har kigget og er ved at gå meget kold i den her, så jeg håber der er en der kan hjælpe :o)
Avatar billede cpufan Juniormester
12. marts 2006 - 21:35 #1
jeg kan ikke se hvor aryArticleID bliver defineret?
Avatar billede cpufan Juniormester
12. marts 2006 - 21:36 #2
har du glemt en include fil?
Avatar billede allan-k Nybegynder
12. marts 2006 - 22:38 #3
den enste include fil der er, er til connection. Men har du en email, så kan jeg sende de to filer, der høre til, en default, samt menu filen.
Avatar billede allan-k Nybegynder
12. marts 2006 - 22:42 #4
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
Avatar billede cpufan Juniormester
12. marts 2006 - 22:54 #5
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"
Avatar billede allan-k Nybegynder
12. marts 2006 - 23:27 #6
Så får jeg denne fejl:
Microsoft OLE DB Provider for SQL Server error '80040e14'

Column 'Article.ArticleID' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.

/menu.asp, line 46
Avatar billede cpufan Juniormester
12. marts 2006 - 23:48 #7
ok så drop det igen,
hvad får du hvis du udskriver

response.write rs.recordcount
Avatar billede cpufan Juniormester
12. marts 2006 - 23:49 #8
eller evt.

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"
Avatar billede allan-k Nybegynder
13. marts 2006 - 15:05 #9
Vedr. den sidste besked kommer denne frem:
Microsoft OLE DB Provider for SQL Server error '80040e14'

Column 'Article.ArticleID' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.

/menu.asp, line 46
Avatar billede allan-k Nybegynder
13. marts 2006 - 19:24 #10
Hvis jeg bruger response, så får jeg 115 frem plus denne fejl:
Microsoft VBScript runtime error '800a0009'

Subscript out of range: 'ArrayIndex'

/menu.asp, line 35
Avatar billede cpufan Juniormester
13. marts 2006 - 21:03 #11
prøv at ændre
For Index = 0 To UBound( aryArticleID ) - 1

til

For Index = LBound(aryarticleid) To UBound( aryArticleID )
Avatar billede allan-k Nybegynder
13. marts 2006 - 21:15 #12
Det er den samme fejl :o(
Microsoft VBScript runtime error '800a0009'

Subscript out of range: 'ArrayIndex'

/menu.asp, line 35
Avatar billede Ny bruger Nybegynder

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.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester