Search code examples
vb.netsqlitesortingalphabetical

how to order names alphabetical from ASC with vb.net


have a code snippet:

  Dim lres As New List(Of DataAttribute)

        If irequest.Param("letter").Value IsNot Nothing Then

 Dim letter As String = "A"
            If irequest.Param.Contains("letter") Then
                Integer.TryParse(irequest.Param("letter").Value, letter)
            End If

            Dim ltable = DataProvider.GetDataTable(Nothing, lres, "USERS", "ORDER BY `Lastname` ASC LIMIT " & letter)

but here struggeling: Lastname` ASC LIMIT " & letter)

want to get data started with A or whatever selected in alphabetical menu.

how to write right LIMIT for Letters??


Solution

  • want to get data started with A or whatever selected

    You do that with a WHERE clause, not with LIMIT:

    WHERE LastName LIKE 'A%'
    

    This will give you only names that start with an 'A'. What you need to do to create an sql statement like that depends on your dataprovider, which you have not shown to us.