none
SQL error SQL does not compare NText, Text, Xml, or Image RRS feed

  • Question

  • Hi, I am developing an application using C# + LINQ. I get an "NotSupportedException" when I try to update values in db. It says "SQL Server does not handle comparision of datatypes NText, Text, Xml or Image".

    This happens in all columns not depending on type declared. This is my query:

    SQL_Tables.

    ProjectDataBaseprjDb = newSQL_Tables.ProjectDataBase(XML.XML_Read.GetCurrentPrjSqlPath(currentProject));

    {

                           

    foreach(varobj inequip)

                                obj.Equipment = thisNewBet.ToString();

                            prjDb.SubmitChanges();

                        }

    Column look like this:

    [

    Column(Name="Equipment", IsDbGenerated=false,CanBeNull=true,DbType="nvarchar(50)")]

           

    publicstringEquipment{ get; set; }

    Please help, i am totally stuck...

    Best Regards Magnus Ericsson

    • Moved by Barry Wang Friday, July 1, 2016 2:37 AM LINQ related
    Thursday, June 30, 2016 1:42 PM

Answers

  • Hi again,

    problem solved, I had a couple of columns of dbType "text". Changed these to "varchar(MAX)" and ... voila everything works as it shoould.  Two thoughts though, 1. Why does "INSERT" work but not "UPDATE"? 2. Shouldnt Microsoft tell about this when starting to work with LINQ?

    Best Regards Magnus

    • Marked as answer by nutten66 Monday, July 4, 2016 6:30 AM
    Monday, July 4, 2016 6:30 AM

All replies

  • Hello nutten66,

    As the question seems related to linq to sql, I'm moving it to the right forum. The UWP forum is about developing Universal Windows apps, your case seems not related to UWP forum.

    Best regards,

    Barry


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 1, 2016 2:41 AM
  • Hi Barry,

    There seem to be something wrong with survey link. When I click it I see a page with text "Page cannot be found".

    Sorry about my choice of forum, first time i am asking questions here so... Better practice next time :)

    Best regards

    Friday, July 1, 2016 5:12 AM
  • Hi nutten66,

    According to your error message, please try the following solutions.<o:p></o:p>

    #solution 1<o:p></o:p>

    open dbml file with xml editor and set the updatecheck to Never, like this:

    <column canbenull="true" dbtype="Xml" name="Equipment" type="System.Xml.Linq.XElement" updatecheck="Never"></column> 

    #solution2

    Change the database field in to a VARCHAR(max)

    #solution3

    change UpdateCheck to WhenChanged  

    <column canbenull="true" dbtype="Xml" name="Equipment" type="System.Xml.Linq.XElement" updatecheck="WhenChanged"></column> 
    

    Best regards,<o:p></o:p>

    Cole Wu<o:p></o:p>



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 1, 2016 7:33 AM
    Moderator
  • Hi Cole,

    thanks for your reply!

    I am quite new to LINQ and SQL so.. Where do I find *.dbml file? Setting all to varchar(max) doesnt it take a lot of unnecessary space in database?

    Maybe stupid questions but new as I said.

    Best Regards Magnus

    Friday, July 1, 2016 10:18 AM
  • Hi again,

    forgot one question.

    Why setting dbType="Xml" and type="System.Sml.Linq.XElement"? It is a string or am I totally missing something here?

    //Magnus

    Friday, July 1, 2016 10:21 AM
  • Hi again,

    problem solved, I had a couple of columns of dbType "text". Changed these to "varchar(MAX)" and ... voila everything works as it shoould.  Two thoughts though, 1. Why does "INSERT" work but not "UPDATE"? 2. Shouldnt Microsoft tell about this when starting to work with LINQ?

    Best Regards Magnus

    • Marked as answer by nutten66 Monday, July 4, 2016 6:30 AM
    Monday, July 4, 2016 6:30 AM