i have created a new form to display the listview that contains the field from my database..i have a problem how to do that..help please

Have a look at THIS link with a code sample.:)

I'm having the same problem. I used the code sample <Modified for tags> but my list view remains blank.

ListView1.View = View.Details
        ListView1.GridLines = True
        ListView1.FullRowSelect = True
        ListView1.HideSelection = False
        ListView1.MultiSelect = False


        ' Create the column headers.
        ListView1.Columns.Add("First Name", 70, _
            HorizontalAlignment.Left)
        ListView1.Columns.Add("Sur Name", 70, _
            HorizontalAlignment.Left)
        ListView1.Columns.Add("Add 1", 70, _
            HorizontalAlignment.Left)
        ListView1.Columns.Add("Add 2", 70, _
            HorizontalAlignment.Left)
        ListView1.Columns.Add("Add 3", 70, _
            HorizontalAlignment.Left)
        ListView1.Columns.Add("Post Code", 70, _
            HorizontalAlignment.Left)

        ' Start with details view.
        ' Select records.
        Dim cmd As New OleDb.OleDbCommand( _
            "SELECT * FROM Books ORDER BY Title", _
            con)

        Dim data_reader As Data.IDataReader = cmd.ExecuteReader()
        Do While data_reader.Read()
            Dim new_item As New  _
                ListViewItem(data_reader.Item("FirstName").ToString)
            new_item.SubItems.Add(data_reader.Item("SurName").ToString)
            new_item.SubItems.Add(data_reader.Item("Add 1").ToString)
            new_item.SubItems.Add(data_reader.Item("Add 2").ToString)
            new_item.SubItems.Add(data_reader.Item("Add 3").ToString)
            new_item.SubItems.Add(data_reader.Item("Post Code").ToString)
            ListView1.Items.Add(new_item)

            Debug.WriteLine(new_item.Text & " : " & _
                new_item.SubItems(0).Text & ", " & _
                new_item.SubItems(1).Text & ", " & _
                new_item.SubItems(2).Text & ", " & _
                new_item.SubItems(3).Text & ", " & _
                new_item.SubItems(4).Text)
        Loop

        ' Close the connection.
        con.Close()
        ' Size the columns to fit the data.
        Dim wid As Integer
        For i As Integer = 0 To ListView1.Columns.Count - 1
            ListView1.Columns(i).Width = -2
            wid += ListView1.Columns(i).Width
        Next i

I'm just trying to figure out how to load listView from ma MS/Jet database

Thanks

Dim rsCount As Integer
        Dim fieldIndex As Integer
        Dim sqlView As String
        sqlView = "SELECT * FROM tblEmployee"
        Open_Con()
        sqlCmd = New OleDbCommand(sqlView, sqlCon)
        sqlDr = sqlCmd.ExecuteReader
        Control.Items.Clear()
        rsCount = 0
        While sqlDr.Read
            Control.Items.Add(sqlDr(0))
            For fieldIndex = 1 To sqlDr.FieldCount - 1
                If IsDBNull(sqlDr(fieldIndex)) Then
                    Control.Items(rsCount).SubItems.Add("-")
                Else
                    Control.Items(rsCount).SubItems.Add(CStr(sqlDr(fieldIndex)))
                End If
            Next
            rsCount = rsCount + 1
        End While
        sqlCmd = Nothing
        sqlDr.Close()
        sqlCon.Close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.