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. Database & SysAdmin
  3. Database
  4. Run dynamic query

Run dynamic query

Scheduled Pinned Locked Moved Database
databasetutorial
4 Posts 4 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.
  • M Offline
    M Offline
    mehrdadc48
    wrote on last edited by
    #1

    Hi, I need to run a dynamic query baseed on a parameter. Actualy I have a comboBox in my report filled with TableNames of my DataSource, now I want to select all records of the selected table. I've filled the combo but I'm confused how to run a different and runtime query

    Best wishes

    D A L 3 Replies Last reply
    0
    • M mehrdadc48

      Hi, I need to run a dynamic query baseed on a parameter. Actualy I have a comboBox in my report filled with TableNames of my DataSource, now I want to select all records of the selected table. I've filled the combo but I'm confused how to run a different and runtime query

      Best wishes

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      If I understand your problem, you can build a string like: mySQL = "select * from " + me.Combobox1.selectedValue Then execute the statement.

      1 Reply Last reply
      0
      • M mehrdadc48

        Hi, I need to run a dynamic query baseed on a parameter. Actualy I have a comboBox in my report filled with TableNames of my DataSource, now I want to select all records of the selected table. I've filled the combo but I'm confused how to run a different and runtime query

        Best wishes

        A Offline
        A Offline
        Ashfield
        wrote on last edited by
        #3

        Either run a parameterised query or a stored proc, passing in the value form your combo box. Try googling either of those terms and you will find many examples.

        Bob Ashfield Consultants Ltd Proud to be a Code Project MVP

        1 Reply Last reply
        0
        • M mehrdadc48

          Hi, I need to run a dynamic query baseed on a parameter. Actualy I have a comboBox in my report filled with TableNames of my DataSource, now I want to select all records of the selected table. I've filled the combo but I'm confused how to run a different and runtime query

          Best wishes

          L Offline
          L Offline
          loyal ginger
          wrote on last edited by
          #4

          If you are using ADO.Net, you can create a command object. By assigning different values to its "CommandText" property, you can conduct queries on different tables. Use ExecuteReader() method to get the result. Please give more details on what API you are trying to use to get access to the database. That way people here can better answer your question.

          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