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

  • Home
  • SEARCH
  • 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 3943294
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:45:54+00:00 2026-05-20T00:45:54+00:00

What is the best approach? I have a C# .NET Web Forms website which

  • 0

What is the best approach? I have a C# .NET Web Forms website which gathers a list of user profiles based on one or more tags. The site connects to a SQL database and uses Stored Procedures for most data retrieval.

My first (half-retarded) thought would be to build a list of parameters: tag1, tag2, tagN. Pass that list to a SP. In the SP, build the WHERE clause by looping through the parameters.

Before i can even do the WHERE loop, how would I build my parameters in SQL?

It’d be nice if I could just pass the SP an array or list to then bust apart and build my query. However, I don’t know how to do this – if I did, I doubt the efficiency would be desirable.

I can use CommandType.Text and spit out a huge query right there in code. That doesn’t sound very efficient either. I want to keep the SQL/C# stuff as separated as possible. This site is already a mess and a half..

Do any of you have thoughts on this?

  • 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-20T00:45:55+00:00Added an answer on May 20, 2026 at 12:45 am

    Table Valued Parameters would be the ideal solution here (assuming you are on SQL Server 2008). They allow you to send sets of data to SQL Server (in 2008 and above) and then process that data as a set in your stored procs (which means you can actually do joins on the set, use EXISTS perhaps, etc).

    If you are not on SQL Server 2008, you have two options, the first being to construct an XML document and then use SQL Server’s XML support (2005 and above) to parse the document entered (through a string or XML parameter) into a data set you can perform your joins/filters on.

    Or, you can also send a custom format which you could use SQL CLR methods to process (any kind of procedural code like parsing generally more performant in SQL CLR methods; SQL Server is better for set-based operations).

    Finally, since you are dynamically generating this query in code, you don’t have to pass a set as a parameter, you can always tack on parameters. However, it goes without saying that you shouldn’t just call ToString and then attach the parameters; you should create a valid parameter name (not hard to do) append that to the set referenced in the IN clause and then add a parameter to the command with the proper value. This makes the assumption that the number of values referenced by your IN clause doesn’t exceed the number of parameters allowed in a command.

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

Sidebar

Related Questions

In our standard web forms ASP.NET solutions we typically have a range of user
Can anyone suggest the best deployment approach for VSeWSS 1.2 based development? I have
I have a question about best practices regarding how one should approach storing complex
We have a scenario using asp.net Forms Authentication in a web farm and need
I just wonder what the best approach is to have multiple users work on
What is the best approach to releasing a new version of a hosted web
Technologies involved : ASP.NET Web-forms Javascript (jQuery for instance) Case To make it clearer
I would really like use the jQuery Validation plugin in my ASP.NET Web Forms
More specifically, What's the best approach for classes where state matters, within an application
I am looking for the best approach to update a website with live data

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.