Welcome to Sign in | Join | Help
in
Home Forums Photos Downloads

Datatype between C# and SQL 2005

Last post 12-08-2006, 2:01 PM by itechcs. 3 replies.
Sort Posts: Previous Next
  •  12-04-2006, 8:31 PM 436

    Datatype between C# and SQL 2005

    I am getting this error when I try to update my database:

     

    The data types text and nvarchar are incompatible in the equal to operator.

     

    The SQL datatype is 'text'

    Here is my SQL statement:

    Here is my SQL statement:

    UpdateCommand="UPDATE [cbc_pages] SET [docID] = @docID, [leftColumn] = @leftColumn, [rightColumn] = @rightColumn, [links] = @links WHERE [id] = @original_id AND [docID] = @original_docID AND [leftColumn] = @original_leftColumn AND [rightColumn] = @original_rightColumn AND [links] = @original_links">

     

     

    As you see the field is a String: <asp:Parameter Name="original_docID" Type="String" />

    asp:Parameter Name="original_docID" Type="String" />
  •  12-04-2006, 9:52 PM 437 in reply to 436

    Re: Datatype between C# and SQL 2005

    You can't use data type TEXT (or NTEXT) in the WHERE clause.  Try casting it as a different datatype (field1 being your TEXT data and field2 being your NVARCHAR data):

    .....where cast(field1 as nvarchar(4000)) = field2


    William Eaton, MCSE
    iTech Computer Solutions, LLC
    www.itechcs.com
  •  12-08-2006, 1:51 PM 451 in reply to 437

    Re: Datatype between C# and SQL 2005

    Thanks,

     

    You would think the IDE would hook me up as I used the IDE to build the statement. But I guess thats the downside of developing with the IDE. I usually code by hand but cutting development time I am trying to rely on the IDE while I learn .NET

  •  12-08-2006, 2:01 PM 452 in reply to 451

    Re: Datatype between C# and SQL 2005

    Depending on how you used the IDE to build it, the IDE may not know what your SQL data type is.  It assumes you know!  Go figure.  :-)
    William Eaton, MCSE
    iTech Computer Solutions, LLC
    www.itechcs.com
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems