DataTable.Select() Method problem..
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: DataTable.Select() Method problem..

  1. #1
    Join Date
    Feb 2009
    Posts
    1

    DataTable.Select() Method problem..

    Hi.

    While executing the following code:


    DataRow[] countryDataRows = destinationsDataSet.Tables[countryDataSetTableName].Select("country_desc = " + country);


    im getting the following exception:
    System.Data.EvaluateException : "Cannot find column [Armenia]." (while country = "Armenia")
    but the column name im running the filter on named "country_desc", why does it thinks that the "country" string variable is the column name? is it something with the underline at the column name?

    thanks...

  2. #2
    Join Date
    Dec 2005
    Location
    algiers, Algeria
    Posts
    132

    Re: DataTable.Select() Method problem..

    try this :
    Code:
    DataRow[] countryDataRows = destinationsDataSet.Tables[countryDataSetTableName].Select("country_desc like '" + country+"'");

  3. #3
    Join Date
    Jan 2009
    Location
    Cochin, India
    Posts
    40

    Smile Re: DataTable.Select() Method problem..

    If you have the exact country name in the variable country then you could try.

    Code:
    DataRow[] countryDataRows = destinationsDataSet.Tables[countryDataSetTableName].Select("country_desc = '" + country + "'");
    That will get you the data rows that match the country name exactly.

    Warm Regards.

    Quote Originally Posted by xenomarz View Post
    Hi.

    While executing the following code:


    DataRow[] countryDataRows = destinationsDataSet.Tables[countryDataSetTableName].Select("country_desc = " + country);


    im getting the following exception:
    System.Data.EvaluateException : "Cannot find column [Armenia]." (while country = "Armenia")
    but the column name im running the filter on named "country_desc", why does it thinks that the "country" string variable is the column name? is it something with the underline at the column name?

    thanks...
    Jay
    Support Resort
    http://www.supportresort.com
    Bringing offshore expertise to the world

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)