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("P ersonid"))
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>
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("P
Loop
PersonListArray = PersonList.ToArray(GetType
If TypeOf drPerson Is DBNull Then
Session.Item("lngPersomid"
Else
Session.Item("lngPersomid"
End If
</code>
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim PersonListArray() As Long instead of Dim PersonListArray As Long()