DataTable.Select(String FilterExpression) : EvaluateException RRS feed

  • Question

  • I use a StoredProcedure to fetch data from my database table into the project's DataTable["HasDiseas"] which has


     DataColumns ["DName"], ["MedicineName"], ["FileID"] three of which are set as PrimaryKey.



    DataRow[] tempdismedic = data.Tables["HasDiseas"].Select("DName= " + DiseasListBox.SelectedItem.ToString());


    foreach (DataRow temp in tempdismedic)





     When i call the Select method of the DataTable and set the Filterexpression as above, i get the EvaluateException


     "Cannot  Find Column [Difteria]"  supposing  (DiseasListBox.SelectedItem.ToString()=="Difteria").


    Whats gone wrong here?





    Wednesday, July 4, 2007 7:51 AM

All replies

  • Hi,

    DName is probably of string type, so you'll have to include your search in quotation marks:

    DataRow[] tempdismedic = data.Tables["HasDiseas"].Select(string.Format("DName='{0}'", DiseasListBox.SelectedItem.ToString()));



    Wednesday, July 4, 2007 8:14 AM