Filtering on dataview

G

Guest

Hello, I'm new on this so please be pacient =)
I'm trying to filter data from a DataView and place de dataview as the
DataSource of a DataGrid.

DsTimeRecording1 --> Dataset
EmployeeID --> GUID
TRDate --> Datetime
dtpDate --> DateTime Picker control on the form
cboName --> ComboBox control on the form; ValueMember = EmployeeID
Error Message --> Operation is not valid for type GUID and string " And
TRDate = "
Code -->
Dim tbl As DataTable = DsTimeRecording1.Tables("TimeRecording")
Dim dv As DataView = New DataView(tbl)

dv.RowFilter = "[EmployeeID] = " & Me.cboName.SelectedValue + " And
TRDate = " & dtpDate.Value
dgTimeRecording.DataSource = dv

Thanks!
 
G

Guest

There's no direct handling of Guids in the RowFilter. You have to convert
the Guid to a string and surround it by apostrophes in the SQL.

dv.RowFilter = "[EmployeeID] = " & Me.cboName.SelectedValue + " And
TRDate = " & dtpDate.Value

--->

dv.RowFilter = "[EmployeeID] = '" & Me.cboName.SelectedValue.ToString() + "'
And
TRDate = " & dtpDate.Value

Note the addition of the ' marks - spaced out it's

ID = ' "

and

+ " '
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top