Object reference not set to an instance of an object.
Try Conn.Open() Dim dt As New DataTable Dim ds As New DataSet ds.Tables.Add(dt) Dim da As New SqlDataAdapter("select * from companies order by sdate DESC", Conn) da.Fill(dt) Dim myrow As DataRow For Each myrow In dt.Rows ListView1.Items.Add(myrow.Item(0)).ToString() ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(1)) ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(2)) ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(3)) ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(4)) ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(5)) Next Conn.Close() Catch ex As SqlException MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error") Conn.Close() 'Catch ex As Exception 'MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error") End Try
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)