Link to home
Start Free TrialLog in
Avatar of Ruffone
Ruffone

asked on

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>
Avatar of jmwheeler
jmwheeler

try this

Dim PersonListArray() As Long    instead of Dim PersonListArray As Long()
Avatar of Ruffone

ASKER

I converted the value being return being returned from the DB from int to bigint and my code works fine now.
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial