Results 1 to 3 of 3

Thread: Concat, Filter - dealing with Arrays

  1. #1
    mcfly is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2009
    Posts
    54
    Reputation
    51

    Concat, Filter - dealing with Arrays

    Hi there,

    I am entering data from a database into an array, the data is entered into the array correctly from the database I think.

    But the problem arises when I try and print out the contents of my array. I get no error but the message I have used for testing prints this:


    Your result-System.Collections.Generic.List`1[System.String]

    It should print the contents of my array, heres the code:

    I think the error is something to do with this line:

    LineOfText = String.Concat("-", ar)


    Code:
    
        Private Sub multiple_dates()
    
            'open calendar information
            'todo move to module call()
            Dim connetionString As String
            Dim oledbCnn As OleDbConnection
            Dim oledbCmd As OleDbCommand
            Dim sql As String
    
            Dim i As Integer
    
            i = 0
    
            sql = ""
            'todo set password and user for database
            connetionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=H:\My Pictures\hotel_db.mdb;User Id=admin;Password=;"
            sql = "Select * from tbl_calendar"
    
            oledbCnn = New OleDbConnection(connetionString)
    
            Try
                'open and prepare connection
                oledbCnn.Open()
                oledbCmd = New OleDbCommand(sql, oledbCnn)
                Dim oledbReader As OleDbDataReader = oledbCmd.ExecuteReader()
                Do While oledbReader.Read
    
                    'move dates from database to listbox
                    'Dim d As Date = CType(oledbReader("date_from"), Date)
                    'ListBox1.Items.Add(d.ToShortDateString())
    
                    Dim cal_id As String
    
                    Dim date_from As String
    
                    Dim date_to As String
    
                    Dim notes As String
    
                    date_from = txtDateFrom.Text
    
                    If oledbReader("date_from") = date_from Then
    
                        Dim ar As New List(Of String)
    
                        cal_id = oledbReader("cal_date_id")
                        ar.Add(cal_id)
                        cal_id = oledbReader("date_from")
                        ar.Add(date_from)
                        date_to = oledbReader("date_to")
                        ar.Add(date_to)
                        notes = oledbReader("notes")
                        ar.Add(notes)
    
                        Dim LineOfText As String
    
                        LineOfText = String.Concat("-", ar)
    
                        MsgBox("Your result" & LineOfText)
    
                    End If
                Loop
    
                oledbReader.Close()
                oledbCmd.Dispose()
                oledbCnn.Close()
            Catch ex As Exception
                'get error message
                MsgBox(ex.GetType.Name & " : " & ex.Message)
            End Try
    
            'get supplier or customer unique id
            Call get_supp_cust()
    
            'get the booking id
            Call get_booking_id()
    
            'get event id and 
            Call get_event_id()
    
            'get address details if any
            Call get_address_details()
    
        End Sub
    The function is called from a calendar control, when ever an event has more than one event/date attached - i would like the user to be able to see the contents of my array (each event on that date) and choose or dismiss the event details. Hope this makes sense, I guess the first problem is trying to get the array details to be printed correctly...

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,188
    Reputation
    2368
    Code:
    LineOfText = String.Join("-", ar.ToArray)
    Concat simply does 's1 & s2' (where ar.ToString would display the type name)

  3. #3
    mcfly is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2009
    Posts
    54
    Reputation
    51
    excellent response as always , many thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking