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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:48:55+00:00 2026-06-08T21:48:55+00:00

I have a search form built in ASP.NET that has a dropdown list which

  • 0

I have a search form built in ASP.NET that has a dropdown list which determines which table to search from. Both tables have similar structure, but the column names are different in places, so I put each table’s information in a separate table. It’s basically set up like this:

Name|Form Field Name|Table Name|Table Column Name

From there I set up a loop that will hold the form field names, the table name, and the column names depending on the selection made in the dropdown list. The loop will take that information and build an separate MySQL query using StringBuilder based on the user’s input. Here’s the loop:

If drFields.HasRows Then
    While drFields.Read()
        If drFields("ASPControlName") <> "" Then
            If strbQuery.ToString <> "" Then
                strbQuery.Append(" AND ")
            End If
            strbQuery.Append(" " & drFields("DBField") & " LIKE '%" & drFields("ASPControlName").ToString & "%' ")
        End If
    End While
End If

My issue, as I’m sure you can tell, is that the drFields(“ASPControlName”), which is filled with something along the lines of txtFirstName.Text.Trim, will only come out to a string with txtFirstName.Text.Trim in it. The variable doesn’t translate to referencing the textbox as I want it to.

I know this is probably a backwards way of doing it, but is it even possible to achieve what I’m trying to? Thanks!

  • 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-08T21:48:56+00:00Added an answer on June 8, 2026 at 9:48 pm

    I know this is probably a backwards way of doing it

    Very true. I wouldn’t continue this route.

    but is it even possible to achieve what I’m trying to?

    Yes, you can use reflection to get a hold of the control and invoke the Property you need to in order to receive the actual value but since this is not a good approach at all, I won’t provide an example.

    Also, building dynamic queries like you describe, need special handling to make sure that you are not exposing yourself to SQL Injection attacks. Try to rethink the strategy here.

    It’s difficult to suggest something that would work for you since I don’t think there’s enough context in the question, but typically, I would opt for creating a stored procedure that would perform the query I need based on certain parameters.

    Some resources that might be helpful:

    • Passing FieldName as Parameter in MySQL Stored Procedure
    • Calling MySQL Prepared Statements from .NET
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a web app that has a built-in search feature that our users
I have a search form on my site that submits the url in the
(Using MySQL and PHP) I have a search form that will allow my users
I have a search form that can search in different provider. I started out
I have built an ASP.NET MVC app some time ago, and after a few
Possible Duplicate: Min Max slider to form I presently have a search module that
I have a search form. I would like when someone type the term, first
I have a search form where user can search for products within their specified
I have a search form with min and max fields. It queries a MySQL
I'm a RoR beginner and am using Rails 3.2.3. I have a search form

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.