locked
Sort and export datagridview RRS feed

  • Question

  • User-960441985 posted

    Hi,

    I need to sort using header and also export to MS Excel. 

    Dim sQuery As String = GetSearchQuery

    ' My query is select SAMPLE_NO_1, SAMPLE_NO_2 , SAMPLE_NO_3 , SAMPLE_NO_4, SAMPLE_NO_5 from Sample_Table (it has 50 fields)

    Dim cmd As New OracleCommand
    cmd.Connection = OraConn
    cmd.CommandText = sQuery
    cmd.CommandType = CommandType.Text

    cmd.ExecuteNonQuery()

    'Create and fill data adaptor
    Dim da As OracleDataAdapter
    da = New OracleDataAdapter(cmd)

    'Create and fill data set
    Dim dt As New DataTable
    da.Fill(dt)

    dgvSearchResults.Visible = True
    dgvSearchResults.DataSource = dt
    dgvSearchResults.DataBind()
    OraConn.Close()
    OraConn.Dispose()

    Thanks a lot.

    Tuesday, April 24, 2018 7:21 PM

All replies