Jump to content

Contar registos na tabela - VB2008

Recommended Posts


Como posso saber quantos registos tem a tabela, em VB2008?

O código que uso é:


            cmd.CommandText = "SELECT * FROM Utilizadores Where NomeUtilizador ='" & cboUtilizadores.Text & "'"

            rsServico = cmd.ExecuteReader


'aqui queria a instrução Select Case rsServico.RecordCount (fazia assim em VB6.0)

' Case > 0


'Case else

'  MsgBox("Não há registos", MsgBoxStyle.OkOnly, "Operação cancelada")

'End Select


        Catch ex As Exception

            MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Falha na Ligação.")

        End Try

Link to post
Share on other sites

Usa o SqlDataReader.HasRows

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.