Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

filtering datagridview values by date range.

$
0
0

Hi,
i have this little project but I'm kinda stuck in the middle and can't move on,
I wan't to filter the result in my datagridview base on current year, and/or first quarter 2nd 3rd, 4th, of the year..
currently what i have so far is to populate the datagridview  with value from database for certain person... 

sorry, im just a newbee here,, im using vb.net 2012 

DataGridView1.Rows.Clear()
        dataConnect()

        myConnection.Open()

        Dim str As String

        str = "SELECT * FROM SSS WHERE (EmpID = '" & IDNo.Text & "')"
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
        dr = cmd.ExecuteReader
        While dr.Read()

            Dim n As Integer = DataGridView1.Rows.Add()

            DataGridView1.Rows.Item(n).Cells(0).Value = dr("DateCovered")

            DataGridView1.Rows.Item(n).Cells(1).Value = dr("BasicSalary")
            DataGridView1.Rows.Item(n).Cells(1).Value = Format(DataGridView1.Rows.Item(n).Cells(1).Value, "Standard")
            DataGridView1.Rows.Item(n).Cells(2).Value = dr("EEAmount")
            DataGridView1.Rows.Item(n).Cells(2).Value = Format(DataGridView1.Rows.Item(n).Cells(2).Value, "Standard")
            DataGridView1.Rows.Item(n).Cells(3).Value = dr("ERAmount")
            DataGridView1.Rows.Item(n).Cells(3).Value = Format(DataGridView1.Rows.Item(n).Cells(3).Value, "Standard")
            DataGridView1.Rows.Item(n).Cells(4).Value = dr("EC")
            DataGridView1.Rows.Item(n).Cells(4).Value = Format(DataGridView1.Rows.Item(n).Cells(4).Value, "Standard")

        End While
        myConnection.Close()
        Me.DataGridView1.Columns("Month").DefaultCellStyle.Format = "dd-MMM-yy"


        

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>