Quote:
I tried redefining "ix as Integer" to "ix as Date" and changing "CInt(lbSearchResults.SelectedItem.ToString)
" to "CDate(lbSearchResults.SelectedItem.ToString)
" and it ERRORS WITH "value of type 'integer' cannot be converted to 'date'"
The error message is quite clear. Assuming that
ID
field is type of integer, you cannot implicity convert it to date/datetime data type.
You have to refer to
REPAIR_DATE
field in according procedure.
Note that there's few other issues in your code:
ToString()
method is redundant:
Dim ix As Integer = MaintenanceDataSetBindingSource.Find("ID", CInt(lbSearchResults.SelectedItem.ToString))
- to filter data by date, i'd suggest to change your code:
DV.RowFilter = cbColName.Text & " = #" & tbSearchInput.Text.Trim & "#"
to:
Dim ci As CultureInfo = CultureInfo.InvariantCulture
Dim stringDate As String = tbSearchInput.Text.Trim
DV.RowFilter = String.Format("{0}=#{1}#", cbColName.Text, stringDate.Format("yyyy/MM/dd", ci))
It's good programming practice to use ISO datetime format. Depending on situation you may need to add time part.
Have a look here: vb.net - How to use BindingSource.Filter for a Date in visual basic 2012? - Stack Overflow[^]
Good luck!