C# - Help with the DataTable.Select() method

Posted on 2009-04-18
Last Modified: 2012-05-06
I've got a DataTable object and I'm trying to run the select method on it to get back an array of DataRows specific to the select string I'm passing in.  The select string that is being passed in  is...
Category = \"Business Expense\" AND Date = 3-09

It is contained within a variable strSelect and I execute my statement like this...
drSelected = dt.Select(strSelect);

I'm getting the following error:
Syntax error: Missing operand anfter 'Expense' operator.

Is my select string not well formed?  How would I need to set it up?
Question by:josephdaviskcrm
    LVL 12

    Accepted Solution


    Use ' instead of double quote
    try this way. Also check the date format
    Category = 'Business Expense' AND Date = '3-09'

    Open in new window


    Author Closing Comment

    That did it.  Thanks.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    This video discusses moving either the default database or any database to a new volume.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    761 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

    10 Experts available now in Live!

    Get 1:1 Help Now