filtering datagridview values by date range.

  • Thread starter Thread starter JhayRubica
  • Start date Start date
J

JhayRubica

Guest
Hi,
i have this little project but Im kinda stuck in the middle and cant move on,
I want 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"

Continue reading...
 
Back
Top