Hello all,
I have a DataGridView that is being populated via SQL with one table and is being filtered by Stock Code. I need to sort the view of one Stock Code by Nutrient names, but the sequence number is in anther SQL table. it would be easy if i could put the sequence in one table but that's not possible, and there are 47 nutrients that need to be sorted in the View. eg, Calories, Fat, Saturated, Trans, cholesterol...

thank you
kyle :)

Why is it not possible to put the sequence in the same query you are populating your DataGridView?

Please show us these 2 queries.

I figured it out :), i wasn't aware that you could use one SQL select statement for multiple tables.

Private Sub BindDataNutr()
        Dim conn As OleDbConnection
        Dim SqlStr As String
        Dim dsNutr As New DataSet
        Dim daNutr As New OleDbDataAdapter
        conn = New OleDbConnection(SysproSqlString())
        SqlStr = "SELECT SBSI_NutritionalInfo.StockCode, SBSI_NutritionalInfo.Nutrient, SBSI_NutritionalInfo.Per100g, SBSI_NutritionalValues.NutrientUom, SBSI_NutritionalInfo.DataSource, SBSI_NutritionalValues.LabelSeq FROM  SBSI_NutritionalInfo INNER JOIN SBSI_NutritionalValues ON SBSI_NutritionalInfo.Nutrient = SBSI_NutritionalValues.Nutrient where StockCode = '" & Trim(Tbx_StkCode.Text) & "' ORDER BY SBSI_NutritionalValues.LabelSeq"
        'SqlStr = "select * From dbo.SBSI_NutritionalInfo where StockCode = '" & Trim(Tbx_StkCode.Text) & "'"
        daNutr = New OleDbDataAdapter(SqlStr, conn)
        DGV_NutrUp.DataSource = dsNutr.Tables(0)
        DGV_NutrUp.Columns("LabelSeq").Visible = False
        DGV_NutrUp.Columns("StockCode").Visible = False
    End Sub
This article has been dead for over six months. Start a new discussion instead.