The "IN_KEYWORD" excpetion in

Posted on 2012-08-28
Last Modified: 2012-08-29
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!
Question by:developer2012
    LVL 74

    Accepted Solution

    What is the value of strbldr at the time the exception is encountered?
    LVL 26

    Expert Comment

    by:Alan Warren
    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)
          ' Populate the DataView with unfiltered data
          dViewEmp = New System.Data.DataView(dsEmp.Tables(0))
        End If

    Open in new window

    Alan ";0)

    Author Comment

    I will try this and let you know. Sorry for the late response...

    Author Comment

    When I put the break point and checked in the database. there is no UID assoicated with that particular  value.resolved my issue. Thanks

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now