• Fill() method returns number of rows successfully added to or refreshed. So if you need to know exactly the number of rows fetch by Fill() (no matter if dt has any rows before Fill ) try

    If dataAdapter.Fill(dt) = 0 Then

    MsgBox("No Record Found", MsgBoxStyle.Critical, "Error")

    Else