Array of long values

I am trying to put the id returned in a datareader into an array of long
values then put that array in a session. But I am getting this error from my
block. I want to ask if anyone could point out why I might be getting this
error.

Error
At least one element in the source array could not be cast down to the
destination array type.

<code>
        Dim PersonList As New ArrayList
        Dim PersonListArray As Long()

        Do While drPerson.Read()
            PersonList.Add(drPerson("Personid"))
        Loop
        PersonListArray = PersonList.ToArray(GetType(Long)) <== Error

        If TypeOf drPerson Is DBNull Then
            Session.Item("lngPersomid") = 0
        Else
            Session.Item("lngPersomid") = CType(PersonListArray, Long())
        End If
</code>
LVL 4
ruffoneAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
NetminderConnect With a Mentor Commented:
PAQed, with points refunded (200)

Netminder
Site Admin
0
 
jmwheelerCommented:
try this

Dim PersonListArray() As Long    instead of Dim PersonListArray As Long()
0
 
ruffoneAuthor Commented:
I converted the value being return being returned from the DB from int to bigint and my code works fine now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.