Solved

Array of long values

Posted on 2004-04-22
5
130 Views
Last Modified: 2010-05-02
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
Comment
Question by:ruffone
5 Comments
 
LVL 11

Expert Comment

by:jmwheeler
ID: 10888182
try this

Dim PersonListArray() As Long    instead of Dim PersonListArray As Long()
0
 
LVL 4

Author Comment

by:ruffone
ID: 10889666
I converted the value being return being returned from the DB from int to bigint and my code works fine now.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11447772
PAQed, with points refunded (200)

Netminder
Site Admin
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now