Imports System.Data.SqlClient
Public Class FrmSupplierList

    Private Sub FrmSupplierList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call GetNum()
        Call GetNum2()
    End Sub
    Public Sub GetNum2()
        Try
            Call opencon()
            Dim myda As New SqlDataAdapter
            With myda
                .SelectCommand = New SqlCommand
                .SelectCommand.CommandText = "SELECT category FROM stock"
                .SelectCommand.Connection = con
            End With
            Dim dr As SqlDataReader = myda.SelectCommand.ExecuteReader
            Dim dt As New DataTable
            dt.Load(dr)
            Me.Label2.Text = dt.Rows.Count.ToString

            Call closecon()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Public Sub GetNum()
        Try
            Call opencon()
            Dim myda As New SqlDataAdapter
            With myda
                .SelectCommand = New SqlCommand
                .SelectCommand.CommandText = "SELECT username FROM login"
                .SelectCommand.Connection = con
            End With
            Dim dr As SqlDataReader = myda.SelectCommand.ExecuteReader
            Dim dt As New DataTable
            dt.Load(dr)
            Me.Label1.Text = dt.Rows.Count.ToString

            Call closecon()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class