The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

in clause

Last post 02-13-2008, 2:26 PM by cano. 3 replies.
Sort Posts: Previous Next
  •  02-13-2008, 12:55 PM 8056

    in clause

    Hi

    I have an issue using the IN clause, need help.

    I'm expecting to get this

    SELECT * FROM [Product] WHERE [ProductID] IN (2640,2638,2639,2633,5094)

    But I get this

    SELECT * FROM [Product] WHERE [ProductID] IN ('2640,2638,2639,2633,5094')

    which returns this error

    Conversion failed when converting the varchar value '2640,2638,2639,2633,5094' to data type int.

    here is the code

      Dim prodColl As New ProductCollection
      prodColl.Query.Where(prodColl.Query.ProductID.In(sfProd.RelatedProducts))
      prodColl.Query.Load()

     BTW the value of sfProd.RelatedProducts is "2639,2638,2640"

    Thanks

    Jaime (Cano) Noriega

     


    Jaime (Cano) Noriega
  •  02-13-2008, 1:40 PM 8057 in reply to 8056

    Re: in clause

    Is sfProd.RelatedProducts a string? If so you need to past in a List of integers such as List<int> which has them in there.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  02-13-2008, 1:59 PM 8058 in reply to 8056

    Re: in clause

    This might help:

    http://community.entityspaces.net/forums/permalink/1947/974/ShowThread.aspx#974


    David Neal Parsons
    www.entityspaces.net
  •  02-13-2008, 2:26 PM 8059 in reply to 8058

    Re: in clause

    Thank you Mike and David for the quick response.

    I'll post the results here just for reference to othere vb'er out there.

    sfProd.RelatedProducts actually contains a list of ID's stored like this "2639,2638,2640"

            Dim prodColl As New ProductCollection
            Dim aList As Object = sfProd.RelatedProducts.Split(",")
            prodColl.Query.Select(prodColl.Query.ProductID)
            prodColl.Query.Where(prodColl.Query.ProductID.In(aList))
            prodColl.Query.Load()
            Debug.WriteLine(prodColl.Query.es.LastQuery)

    query looks like this

    SELECT [ProductID] FROM [Product] WHERE [ProductID] IN ('2639','2638','2640')

    dosen't get any easier than this.

    Thanks again

    BTW: tried the code formatter but no luck :(


    Jaime (Cano) Noriega
View as RSS news feed in XML