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 6974745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:16:40+00:00 2026-05-27T17:16:40+00:00

That’s what I tried & failed: string sql = … WHERE [personID] IN (@sqlIn)

  • 0

That’s what I tried & failed:

      string sql = "... WHERE [personID] IN (@sqlIn) ...";
      string sqlIn = "1,2,3,4,5";
      SqlCeCommand cmd.Parameters.Add("@sqlIn", SqlDbType.NText).Value = sqlIn;

      SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
      da.Fill(ds); // > Error

Error details:

The ntext and image data types cannot be used in WHERE, HAVING, GROUP BY, ON, or IN clauses, except when these data types are used with the LIKE or IS NULL predicates.

Can’t I pass all the IDs as one parameter? Should I add one by one all IDs?

P.S: Notice SqlCE

  • 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-05-27T17:16:41+00:00Added an answer on May 27, 2026 at 5:16 pm

    You can’t parameterise that as a single parameter. Your query is doing an “in” on a single value, so is essentially:

    ... Where personId = '1,2,3,4,5'
    

    (give or take a parameter). This is usually also an invalid or sub-optimal equality test, and certainly isn’t what you were trying to query.

    Options;

    • use raw concatenation: often involves a SQL injection risk, and allows poor query plan re-use
    • on full SQL server: use a UDF to split a single param
    • on full SQL server, use a TVP
    • add parameters dynamically, and add the various @param3 etc to the TSQL

    The last is the most reliable, and “dapper-dot-net” has a feature built in to do this for you (since it is commonly needed):

    int[] ids = ...
    var rows = conn.Query<SomeType>(
        @"... Where Id in @ids",
        new { ids }).ToList();
    

    This, when run via dapper-dot-net, will add a parameter per item in “ids”, giving it the right value etc, and fixing the SQL so it executes, for example:

    "... Where Id in (@ids0, @ids1, @ids2)"
    

    (if there were 3 items in “ids”)

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's the question. Give only one reason you think why have OODB failed or
I've got a string that has curly quotes in it. I'd like to replace
That is, I'd like to have a tuple of values. The use case on
That's it. If you want to document a function or a class, you put
That's it. It's a dumb dumb (embarrassing!) question, but I've never used C# before,
That's basically the question, is there a right way to implement operator<< ? Reading
that one has been nagging me ever since I dabbled in web developpement; is
That's the question... Do you think ASP.Net is a technology suitable for high-load sites?

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.