.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Filtering a dataset using select method

Posted By:satyapriyanayak       Posted Date: May 02, 2013    Points: 40    Category:    URL: http://www.dotnetspark.com  

Filtering a dataset using select method
 

Imports System.Data
Imports System.Data.OleDb
Public Class Form1
    Dim ConnectionString As String = System.Configuration.ConfigurationSettings.AppSettings("dsn")
    Dim con As OleDbConnection = New OleDbConnection(ConnectionString)
    Dim com As OleDbCommand
    Dim oledbda As OleDbDataAdapter
    Dim ds As DataSet
    Dim dt As DataTable
    Dim str As String
    Private Sub btnfilterdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfilterdata.Click
        Try
            con.Open()
            str = "select * from student"
            com = New OleDbCommand(str, con)
            oledbda = New OleDbDataAdapter(com)
            ds = New DataSet
            oledbda.Fill(ds, "student")
            dt = ds.Tables("student")
            Dim s1 As String
            Dim s2 As String
            s1 = "smarks>60"
            s2 = "smarks asc"
            Dim result() As DataRow
            result = dt.Select(s1, s2)
            Dim ctr As Integer
            For ctr = 0 To (result.Length - 1)
                ListBox1.Items.Add(result(ctr)("smarks"))
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        con.Close()
    End Sub
End Class


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend