none
Issue using DataTable.Select method RRS feed

  • Question

  • Hi everyone,

                  I'm having a problem when I try to filter a DataTable using the Select method on a Guid Field.

    I have a field type Guid (unique identifier) for a countryId column. When I try to filter using it, I get an empty DataRow [] array.



    I think this probably happends because the DataTable.Select method implementation does not compare the Guid with the string filterexpression because they are different types (but it does not throw an exception),



    Can anybody help me with this ? Any idea how can I filter using that field ?



    Thanks in advance.

    Wednesday, July 11, 2007 2:37 AM

All replies

  • Did you put single quotes around GUID value when you constructed filter condition, like

     

    MyDataTable.Select ("Mycolumn='" & GuidValueHere & "'")

     

    You could also try to use CONVERT function inside of the filer condition. If I remember correctly syntax, it should be like

     

    MyDataTable.Select ("Mycolumn=CONVERT('" & GuidValueHere & "', 'System.GUID')")

    Wednesday, July 11, 2007 10:54 AM
    Moderator
  • Thanks VMazur for your help. After I did the post to the forum I realized I had an error in my database. After fixing it, the Select method work ok for the Guid type.

     

    Thanks again.

     

    Regards.

    Wednesday, July 11, 2007 1:30 PM