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!
developer2012Asked:
Who is Participating?
 
käµfm³d 👽Commented:
What is the value of strbldr at the time the exception is encountered?
0
 
Alan WarrenApplications DeveloperCommented:
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)
0
 
developer2012Author Commented:
I will try this and let you know. Sorry for the late response...
0
 
developer2012Author Commented:
When I put the break point and checked in the database. there is no UID assoicated with that particular  value.resolved my issue. Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.