Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Inserting table field into query string

Inserting table field into query string

Scheduled Pinned Locked Moved ASP.NET
databasemysqlsql-servertutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nakins
    wrote on last edited by
    #1

    Hello, I have what I think is a simple task, but I have yet to find the answer. I'm trying to insert a table field into a query string from a dropdown list. I'm using MySql for a database, and if I use a control parameter, it inserts the selected value from the dropdown into the query with single quotes, like 'xxx'. MySql wants field name to be unquoted, like xxx. My query is like SELECT name, number, city FROM mytable WHERE xxx LIKE 'something';. And I can't figure out how to insert the xxx into the query without the quotes. I was wondering if any of you have ever done something like this where you entered a field name into a query string. I'm sure this is done somehow. I can't imagine not being able to do this. Any suggestion, and I mean ANY suggestion will be welcomed. How would you do it with MSsql or access?

    C 1 Reply Last reply
    0
    • N nakins

      Hello, I have what I think is a simple task, but I have yet to find the answer. I'm trying to insert a table field into a query string from a dropdown list. I'm using MySql for a database, and if I use a control parameter, it inserts the selected value from the dropdown into the query with single quotes, like 'xxx'. MySql wants field name to be unquoted, like xxx. My query is like SELECT name, number, city FROM mytable WHERE xxx LIKE 'something';. And I can't figure out how to insert the xxx into the query without the quotes. I was wondering if any of you have ever done something like this where you entered a field name into a query string. I'm sure this is done somehow. I can't imagine not being able to do this. Any suggestion, and I mean ANY suggestion will be welcomed. How would you do it with MSsql or access?

      C Offline
      C Offline
      colin mcadam
      wrote on last edited by
      #2

      use String.Replace("'","") on the field name string you ar inserting into your query this would remove the 's

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups