Vb.Net - Total registration in descending order

Asked

Viewed 175 times

0

inserir a descrição da imagem aquiI created a project in VB.NET in it when searching for the code shows me the total of record that that call has, but I need it in descending order since when searching my form always loads the last record.

Follows the Code -

Private Sub CarregaTabela()

    ' ----- Pega a Qtd do registro de um chamado -------------

    stSQL = "SELECT COUNT(*) AS QTD FROM  PROVIDENCIA WHERE COD_OCORRENCIA = '" + txtCodOcorrencia.Text.PadLeft(10, "0") + "' "
    comCommand = New OleDb.OleDbCommand(stSQL, conBase)
    comCommand.CommandType = CommandType.Text
    darProvidencia = comCommand.ExecuteReader()

    darProvidencia.Read()
    dtx = Convert.ToInt32(darProvidencia("QTD"))

End Sub 

'----------- Páginação - posição dos botões  ----------------------------------------------------
Private Sub MovimentarRegistro(ByVal e As eRegistro)
    Select Case e
        Case eRegistro.Primeiro

            If posicao > 0 Then posicao -= 1

        Case eRegistro.Ultimo
            If posicao < (dtx - 1) Then posicao += 1
        Case Else
            posicao = dtx - 1
    End Select
End Sub 

Att,

1 answer

0

It would be something like:

SELECT COUNT(*), ID FROM TABELA GROUP BY ID ORDER BY ID DESC 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.