varSQL = varSQL & "ORDER BY " & myField & " " & mySort & ";" cmd = New SqlCommand(varSQL, con) rd = cmd.ExecuteReader Dim lsv As ListViewItem While rd.Read lsv = New ListViewItem(rd("JOBNO").ToString) 'lsv.Checked = True lsv.SubItems.Add(rd("ContainerNo").ToString) lsv.SubItems.Add(rd("CartonFrom").ToString) lsv.SubItems.Add(rd("PO").ToString) lsv.SubItems.Add(rd("Style").ToString) lsv.SubItems.Add(rd("Color").ToString) lsv.SubItems.Add(rd("CartonSize").ToString) lsv.SubItems.Add(rd("ShipMent").ToString) lsv.SubItems.Add(rd("Factory").ToString) lstvwJobNo.Items.Add(lsv) End While Cursor.Current = Cursors.Default Return List_dgJobNo = 1 Catch ex As Exception MessageBox.Show(ex.ToString) Return List_dgJobNo = -1 Finally If con.State = ConnectionState.Open Then con.Close() End If End Try End Function |