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
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)