Imports MySql.Data.MySqlClient

Public Class Form1
    Public sConnection As New MySqlConnection
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If sConnection.State = ConnectionState.Closed Then
            sConnection.ConnectionString = "SERVER = localhost; USERID = root; PASSWORD =; DATABASE = vb;"
            sConnection.Open()
        End If

        LoadPeople()

    End Sub

    Public Sub LoadPeople()
        Dim sqlQuery As String = "SELECT * FROM tbl_people"
        Dim sqlAdapter As New MySqlDataAdapter
        Dim sqlCommand As New MySqlCommand
        Dim TABLE As New DataTable
        Dim i As Integer

        With sqlCommand
            .CommandText = sqlQuery
            .Connection = sConnection
        End With

        With sqlAdapter
            .SelectCommand = sqlCommand
            .Fill(TABLE)
        End With

        For i = 0 To TABLE.Rows.Count - 1
            With lvPeople
                .Items.Add(TABLE.Rows(i)("id"))
                With .Items(.Items.Count - 1).SubItems
                    .Add(TABLE.Rows(i)("fname"))
                    .Add(TABLE.Rows(i)("mname"))
                    .Add(TABLE.Rows(i)("lname"))
                End With
            End With
        Next
    End Sub
End Class

please put break point in Loadpeople method and see are you getting the connectionto DB? and are you getting any records in TABLE

This article has been dead for over six months. Start a new discussion instead.