Trying to resort results on click

pryspr01

Member
Joined
Jan 5, 2006
Messages
15
Programming Experience
Beginner
Trying to get records to resort when this menu item is clicked, the text is showing up by its not reordering. Is there a concept im missing here?

VB.NET:
    Private Sub MenuItem10_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem10.Click

        'not yet working?
        Dim intposition As Integer
        Dim objcommand As SqlCommand = New SqlCommand

        intposition = objcurrencyManager.Position

        objcommand.Connection = objconnection
        objcommand.CommandText = "SELECT * FROM ProspectTable ORDER BY StudentID"
        objcommand.CommandType = CommandType.Text

        objconnection.Open()

        Try
            objcommand.ExecuteNonQuery()

        Catch sqlexceptionerr As SqlException
            MessageBox.Show(sqlexceptionerr.Message)


        End Try

        objconnection.Close()

        FillDataSetandView()
        BindFields()

        objcurrencyManager.Position = intposition

        Showposition()

        StatusBar1.Text = "Records Sorted By Student ID."
    End Sub
 
You don't need to perform another query to sort existing data. Just set the DefaultView.RowFilter property of your DataTable. Depnding on how you are displaying your data you may need to rebind the DataTable.
 
Back
Top