Hi,
I am trying to filter a binding source by a date field in a datagridview (using vb.net 2010 and sql server 2008)
Now my filter works for names no problem but not for dates ! Dates in the database are proper dates in the yyyy/mm/dd format !
Heres my code I followed an example on the web, but cant find any other examples that might help?
bs1 is the binding source ! No error is produced though!
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
'Search by Client ID
Dim Ans As String
Try
Ans = InputBox("Search For DOB..(format.31/12/1961", "Search", "", 100, 100)
If Ans = "" Then
MsgBox("No Date entered")
Else
bs1.Filter = ("DOB = #' & Ans & '#")
DataGridView1.DataSource = bs.DataSource
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error!")
End Try
End Sub
Help !
I am trying to filter a binding source by a date field in a datagridview (using vb.net 2010 and sql server 2008)
Now my filter works for names no problem but not for dates ! Dates in the database are proper dates in the yyyy/mm/dd format !
Heres my code I followed an example on the web, but cant find any other examples that might help?
bs1 is the binding source ! No error is produced though!
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
'Search by Client ID
Dim Ans As String
Try
Ans = InputBox("Search For DOB..(format.31/12/1961", "Search", "", 100, 100)
If Ans = "" Then
MsgBox("No Date entered")
Else
bs1.Filter = ("DOB = #' & Ans & '#")
DataGridView1.DataSource = bs.DataSource
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error!")
End Try
End Sub
Help !
Last edited: