Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:08:26+00:00 2026-06-12T09:08:26+00:00

I use this code to select from a table in SQL Server 2008: sqlcomm.CommandText

  • 0

I use this code to select from a table in SQL Server 2008:

sqlcomm.CommandText = "select [objId] from [tablename] where href = @href"

The type of href in my table is ntext and I use this code to select:

 sqlcomm.Parameters.Add("@href", SqlDbType.NVarChar);
 sqlcomm.Parameters["@href"].Value = 'somestring';
 IDataReader reader = sqlcomm.ExecuteReader();

But it errors:

The data types ntext and varchar are incompatible in the equal to operator

When I use SqlDbType.NText it have same error. I can’t change type of href column in my table. When I use like @href it works, but I couldn’t use LIKE because I want to exact match.

How can I solve my problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:08:27+00:00Added an answer on June 12, 2026 at 9:08 am

    The error is what it says. You cannot compare an NTEXT column with a NVarchar parameter.

    sqlcomm.CommandText="select [objId] from [tablename] where cast(href as nvarchar(max))=@href"
    

    ntext, text, and image (Transact-SQL) have been deprecated for a while now. Look to convert them to n/varchar(max) and varbinary(max) as soon as practicable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this code to select password field from the sql server 2012 db,
now i use this code: $welcome_text = mysql_query(SELECT * FROM `text` WHERE `name` =
I use this code to connect to SQL Server 2012, but it does not
I am trying to connect the sql server 2008 with servlet.this is my code.
When I select an element by name in Javascript, I usually use this code:
I use this code to update data in database table. Can reuse same code
I use this code to process a date string coming in from a json
We're upgrading from SQL Server 2005 to 2008. Almost every database in the 2005
this sp was written for SQL Server and then 'converted ' for use in
I'm trying to alter multiple SQL Server 2008 R2 tables at one time. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.