[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/31/2007 at 03:14AM PDT, ID: 22604122
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

BC30311: Value of type 'System.Collections.ArrayList' cannot be converted to '1-dimensional array of ContactDetails'.

Asked by Natchiket in Programming for ASP.NET

Tags: cannot, converted, value

Hi ASP.noob here .... So I'm using this expensive book (ASP.NET 2.0 Moroney & MacDonald) to try and learn ASP.NET and in the code below I'm following the book examples to try and build the database abstraction layer... only trouble is I can't get it to work & neither can the ASP.NET compiler...

The error occurs on the line

Return alC



ports Microsoft.VisualBasic

Public Class ContactDetails

    Dim lngID As Integer
    Dim strFN, strLN As String

    Public Property ID() As Integer
        Get
            Return lngID
        End Get
        Set(ByVal value As Integer)
            lngID = value
        End Set
    End Property

    Public Property FirstName() As String
        Get
            Return strFN
        End Get
        Set(ByVal value As String)
            strFN = value
        End Set
    End Property

    Public Property LastName() As String
        Get
            Return strLN
        End Get
        Set(ByVal value As String)
            strLN = value
        End Set
    End Property


    Public Sub New(ByVal intID As Integer, ByVal strFN As String, ByVal strLN As String)
        Me.ID = intID
        Me.FirstName = strFN
        Me.LastName = strLN
    End Sub
End Class

Public Class SESDB
    Dim strCS As String   'Connection string
    Dim strSC As String   'Search Criteria

    Public Property SearchCriteria() As String
        Get
            SearchCriteria = strSC
        End Get
        Set(ByVal value As String)
            strSC = value
        End Set
    End Property


    Public Function SearchContacts() As ContactDetails()
        Dim cnn As New Data.OleDb.OleDbConnection(strCS)
        Dim cmd As New Data.OleDb.OleDbCommand

        Dim strSQL As String
        Dim alC As New ArrayList

        Try
            strSQL = "SELECT cID,FirstName,LastName FROM tblContacts WHERE LastName='" & strCS & "'"
            cnn.Open()
            cmd.CommandType = Data.CommandType.Text
            cmd.CommandText = strSQL

            Dim rdr As Data.OleDb.OleDbDataReader = cmd.ExecuteReader()
            Do While rdr.Read
                Dim cntct As New ContactDetails( _
                CInt(rdr("cID")), _
                CStr(rdr("FirstName")), _
                CStr(rdr("LastName")))
                alC.Add(cntct)
            Loop
            rdr.Close()
            Return alC  <----- Error here!





        Catch ex As Exception
            Throw New ApplicationException("Data Error")

        Finally
            cnn.Close()

        End Try







    End Function

    Public Sub New()
        strCS = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("SES").ConnectionString
    End Sub
End Class
[+][-]05/31/07 03:26 AM, ID: 19186785

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for ASP.NET
Tags: cannot, converted, value
Sign Up Now!
Solution Provided By: KarinLoos
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05/31/07 03:37 AM, ID: 19186837

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74