How to Order a DataGrid

Hi All
How can I order my datagrid like I do in asp.net
SELECT * FROM Tabla1 ORDER BY OrderId DESC

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

DataSet11.Clear()

OleDbDataAdapter1.Fill(DataSet11)

DataGrid1.DataSource = DataSet11.Inventario

End Sub

Best Regards



Answer this question

How to Order a DataGrid

  • Ramirez3964

    Hi
    I just found the

    'OleDbSelectCommand1

    Me.OleDbSelectCommand1.CommandText = "SELECT Entro, Codigo, Cantidad, Altura, Descripcion, Costo, Precio, Totalfina" & _

    "l FROM Inventario ORDER BY Id DESC"

    Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1

    Let me know if you have a better way!
    THX
    Best Regards
    Primillo


  • Simsabim

    try using a DataView as the datasource of your grid.
    DataViews can be filtered and sorted.

  • How to Order a DataGrid