title: Sorting information in Datagrid
body: <p>I have a datagrid linked to an access database in VB6. how do i sort the data in ascending order when the user clicks the command button. </p>
  
  <p>My Code:</p>
  
  <pre><code>Private Sub Form_Load()
    connSearch.Open connstr
    Adodc1.ConnectionString = Conn.connstr
    Set StudentTable.DataSource = Adodc1
    Adodc1.Visible = False
  End Sub
  
  Private Sub cmdSort_Click()
    Dim LNsql As String
    connSearch.Close
    connSearch.Open connstr
    LNsql = "select * from Table1 order By LastName" &amp; " " &amp; StudentTable.Columns(2).Caption &amp; "Asc"
    StudentTable.Refresh
  End Sub
  </code></pre>