Hi group,
I've been playing with a ListView and I'm struggling to get it to populated with info in a database. I'm hoping you may see something in my code that is creating the error.
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim rdr As SqlDataReader = cmd.ExecuteReader
con.ConnectionString = ("Data Source=DON-PC;Initial Catalog=DataDesignSolutions;Integrated Security=True;User ID=DON-PC;Password=be67011;")
Dim command As New SqlCommand("", con)
command.CommandText = "SELECT * FROM PRINTERMAINT"
lvPrinterSetup.Items.Clear()
con.Open()
rdr = cmd.ExecuteReader
Do While rdr.Read()
lvPrinterSetup.Items.Add(New ListViewItem({rdr(0), rdr(1), rdr(2), rdr(3), rdr(4)}))
Loop
rdr.Close()
con.Close()
To clarify, there are 5 columns in this data table (PRINTERMAINT). They are "PrinterID", "PrinterName", "PrinterNumber", "PrinterLocation" and "PrinterAddress".
Currently, I've attempted to push up at least 3 records. While I've not confirmed they are there, I believe they are.
If you see something that may be creating the failure, please speak up. I'm not getting any kind of error message. I'm just not getting any data to display in the ListView.
Thanks for your help.
Don