Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Sub loadlistview()
        Me.ListView1.View = View.Details
        Me.ListView1.GridLines = True
        Dim conn As New SqlConnection("Data Source=localhost;Initial Catalog=TrackingUnitsInventorySystem;Integrated Security=True")
        conn.Open()
        ListView1.Items.Clear()
        ListView1.Columns.Clear()
        Dim cmd As New SqlCommand("SELECT * from vSale", conn)
        cmd.CommandType = CommandType.Text
        Dim reader As SqlDataReader = cmd.ExecuteReader()
        Me.ListView1.Columns.Add("IMEI No")
        Me.ListView1.Columns(0).Width = 150
        Me.ListView1.Columns.Add("Invoice No")
        Me.ListView1.Columns(1).Width = 100
        Me.ListView1.Columns.Add("Alternate Code")
        Me.ListView1.Columns(2).Width = 100
        Me.ListView1.Columns.Add("SaleOrder")
        Me.ListView1.Columns(3).Width = 150
        Me.ListView1.Columns.Add("Status")
        Me.ListView1.Columns(4).Width = 150
        Me.ListView1.Columns.Add("Accessroy Type/Category")
        Me.ListView1.Columns(5).Width = 150
        Me.ListView1.Columns.Add("Origin")
        Me.ListView1.Columns(6).Width = 100
        Me.ListView1.Columns.Add("Warranty")
        Me.ListView1.Columns(7).Width = 150
        Me.ListView1.Columns.Add("Company")
        Me.ListView1.Columns(8).Width = 100
        Me.ListView1.Columns.Add("Sale Date")
        Me.ListView1.Columns(9).Width = 100
        Me.ListView1.Columns.Add("Party Name")
        Me.ListView1.Columns(10).Width = 150
        Me.ListView1.Columns.Add("Received By")
        Me.ListView1.Columns(11).Width = 150
        Me.ListView1.Columns.Add("Receiving Medium")
        Me.ListView1.Columns(12).Width = 100
        Me.ListView1.Columns.Add("Unit Quantity")
        Me.ListView1.Columns(13).Width = 150
        Me.ListView1.Columns.Add("Total to Party")
        Me.ListView1.Columns(14).Width = 100
        Me.ListView1.Columns.Add("Total Sold")
        Me.ListView1.Columns(15).Width = 100
        Me.ListView1.Columns.Add("Remarks")
        Me.ListView1.Columns(16).Width = 100
        While reader.Read()
            Dim NewItem As New ListViewItem
            With NewItem
                .Text = reader("IMEINo").ToString
                With .SubItems
                    .Add(reader("InvoiceNo").ToString)
                    .Add(reader("AlternateCode").ToString)
                    .Add(reader("SaleOrder").ToString)
                    .Add(reader("Status").ToString)
                    .Add(reader("Category").ToString)
                    .Add(reader("Origin").ToString)
                    .Add(reader("Warranty").ToString)
                    .Add(reader("Company").ToString)
                    .Add(reader("SaleDate").ToString)
                    .Add(reader("PartyName").ToString)
                    .Add(reader("Recviedby").ToString)
                    .Add(reader("RecviedThrough").ToString)
                    .Add(reader("UnitQty").ToString)
                    .Add(reader("SoldToParty").ToString)
                    .Add(reader("TotalSold").ToString)
                    .Add(reader("Remarks").ToString)
                    ListView1.Items.Add(NewItem)
                End With
            End With

        End While
        reader.Close()
        conn.Close()
    End Sub
Posted
Updated 12-Apr-13 2:52am
v2
Comments
Hemant Singh Rautela 12-Apr-13 4:31am    
you can test your code yourself, by use of breakpoints and step by step debugging, then you can get where is the problem...
ZurdoDev 12-Apr-13 8:53am    
If it is showing multiple times it must be in your reader, right? Have you put a breakpoint to see what is happening?
DinoRondelly 12-Apr-13 13:34pm    
This is every record or just some? are you sure there arent any duplicates or in your care triplicate records in your table?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900