SharePoint User Group UK

Share the knowledge!

Welcome to SharePoint User Group UK Sign in | Join | Help
in
Home Blogs Forums Photos Files Roller

SPQuery Error when using a Note Field and Neq camel operator on that field

Last post 08-07-2008, 4:26 PM by Cimares. 7 replies.
Sort Posts: Previous Next
  •  08-06-2008, 2:53 PM 12760

    SPQuery Error when using a Note Field and Neq camel operator on that field

    When i try to execute a caml query with a caml like:

    "<Where><Neq><FieldRef Name="MyNoteField" /><Value Type="Note">any string here</Value></Neq></Where>"

    I get the following exception:
    System.Data.SqlClient.SqlException: The data types ntext and nvarchar are incomp
    atible in the not equal to operator.

    I tried to use diferent operators and like 'Eq' and 'BeginWith' and had no problems.

    Is this a known issue? or is a problem in my sharepoint installation?

    I am running wss v3 with service pack 1


    Thanks,
    Santiago Ferreira
  •  08-07-2008, 9:04 AM 12796 in reply to 12760

    Re: SPQuery Error when using a Note Field and Neq camel operator on that field

    Try this tool to create (or test your) query:

    http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1252

    Thanks,

    Alex

  •  08-07-2008, 2:40 PM 12816 in reply to 12796

    Re: SPQuery Error when using a Note Field and Neq camel operator on that field

    Thanks Alex for the answer.
        I tried the U2U caml query tool, i always use it (it's a great tool!) but the same error happends. It throws the exception.







  •  08-07-2008, 2:49 PM 12818 in reply to 12760

    Re: SPQuery Error when using a Note Field and Neq camel operator on that field

    Santiago, Where are you getting the Value type="Note" from? try changing this to "Text" and re-running the query.

    What field type is MyNoteField?

    Paul.


    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
  •  08-07-2008, 2:59 PM 12820 in reply to 12818

    Re: SPQuery Error when using a Note Field and Neq camel operator on that field

    Hi Paul, thanks for the answer,

        MyNoteField is a multi line field type (internal type is Note). I also tried to change in the caml query the line "<Value Type="Note">" with "<Value Type="Text">" and "<Value>". The problem is not this part of the query, if i change the caml operator to 'Eq' or to 'BeginWith' i have no problem at all. Also if i change the target field to a field with other type (like "Text") it works fine.

        Can you reproduce the error? if not, i guess is my installation otherwise is a sharepoint bug

    Thanks a lot for the help
    Santiago Ferreira
  •  08-07-2008, 3:13 PM 12822 in reply to 12820

    Re: SPQuery Error when using a Note Field and Neq camel operator on that field

    I think I agree with you, it looks like you can't use the Neq operator against multiline types. I've used it many times on simple text fields without any problem.

    I've just created a new column and it doesn't work with U2U's caml builder.. I'm guessing it just doesn't like a text comparison with the multiline string, not sure how this is stored in the object model, possible a string array in which case I can udnerstand the comparison not working. I just tried and you can't use Equal either.. You can use begins with though!

    Paul.


    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
  •  08-07-2008, 3:30 PM 12826 in reply to 12822

    Re: SPQuery Error when using a Note Field and Neq camel operator on that field

    Thanks!

    Now that i know is not my sharepoint installation i'll look for more information on the web about which operators can be applied to every field type. Do you know if such a list even exists?
  •  08-07-2008, 4:26 PM 12831 in reply to 12826

    Re: SPQuery Error when using a Note Field and Neq camel operator on that field

    I believe the WSS SDK has some detail on this but I've not examined it. Probably a good place to start tho.
    www.myfatblog.co.uk
    MCTS: WSS 3.0
    MCTS: MOSS 2007
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems