• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 136
  • Last Modified:

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>
0
ruffone
Asked:
ruffone
1 Solution
 
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
 
NetminderCommented:
PAQed, with points refunded (200)

Netminder
Site Admin
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now