Link to home
Start Free TrialLog in
Avatar of developer2012
developer2012

asked on

The "IN_KEYWORD" excpetion in vb.net?

I get this exception when I  selected the particular value from the drop down list. It does not happen with other values but just with the one.
The IN keyword must be followed by a non-empty list of expressions separated by commas, and also must be enclosed in parentheses.
HEre is the code

     Dim dViewEmp As DataView = New DataView(dsEmp.Tables(0), "UID  not in (" & strbldr.ToString & ")", "UID", DataViewRowState.CurrentRows)

Open in new window


Any ideas? It works good with other selected values.  Thanks!
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi developer2012,
maybe something like this:
    Dim strbldr As New StringBuilder
    ' populate your stringbuilder with ID's like "1,2,3,4,5,6,207,901"
    
    Dim dViewEmp As System.Data.DataView = Nothing
    
    If strbldr.ToString.Length > 0 Then
      ' Populate the DataView with filtered data.
      dViewEmp = New System.Data.DataView(dsEmp.Tables(0), "UID  not in (" & strbldr.ToString & ")", "UID", System.Data.DataViewRowState.CurrentRows)
    Else
      ' Populate the DataView with unfiltered data
      dViewEmp = New System.Data.DataView(dsEmp.Tables(0))
    End If

Open in new window

Alan ";0)
Avatar of developer2012
developer2012

ASKER

I will try this and let you know. Sorry for the late response...
When I put the break point and checked in the database. there is no UID assoicated with that particular  value.resolved my issue. Thanks