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. General Programming
  3. Visual Basic
  4. Creating query from multiple combo boxes

Creating query from multiple combo boxes

Scheduled Pinned Locked Moved Visual Basic
databasehelplounge
7 Posts 3 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.
  • S Offline
    S Offline
    Shrimpersfan
    wrote on last edited by
    #1

    Hi there. I have a form with 3 combo boxes on, each with a random number of items in them. What I am trying to do is to let the user select items from the combo boxes and then generate the sql query based on what they had selected, i would then want to display the results of this query in a datagrid view. I am fairly sure i will need to use a sproc to pass parameters for the fields i will need from the app to the database but i am pretty much a vb novice and have only recently started using sql connections through it. Any help would be greatly appreciated.

    C 1 Reply Last reply
    0
    • S Shrimpersfan

      Hi there. I have a form with 3 combo boxes on, each with a random number of items in them. What I am trying to do is to let the user select items from the combo boxes and then generate the sql query based on what they had selected, i would then want to display the results of this query in a datagrid view. I am fairly sure i will need to use a sproc to pass parameters for the fields i will need from the app to the database but i am pretty much a vb novice and have only recently started using sql connections through it. Any help would be greatly appreciated.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You don't need a stored proc, although if you don't use one, you would do well to use parameterised queries. However, if the text comes from a combobox, there's probably no harm in string mashing your SQL together. Do you know how to do any of this, or are you hoping to have it all explained for you ?

      Christian Graus Driven to the arms of OSX by Vista.

      T S 2 Replies Last reply
      0
      • C Christian Graus

        You don't need a stored proc, although if you don't use one, you would do well to use parameterised queries. However, if the text comes from a combobox, there's probably no harm in string mashing your SQL together. Do you know how to do any of this, or are you hoping to have it all explained for you ?

        Christian Graus Driven to the arms of OSX by Vista.

        T Offline
        T Offline
        Tom Deketelaere
        wrote on last edited by
        #3

        Christian Graus wrote:

        there's probably no harm in string mashing your SQL together.

        True but he can still use parameters for that extra security :) (its just a little bit more code)

        C 1 Reply Last reply
        0
        • C Christian Graus

          You don't need a stored proc, although if you don't use one, you would do well to use parameterised queries. However, if the text comes from a combobox, there's probably no harm in string mashing your SQL together. Do you know how to do any of this, or are you hoping to have it all explained for you ?

          Christian Graus Driven to the arms of OSX by Vista.

          S Offline
          S Offline
          Shrimpersfan
          wrote on last edited by
          #4

          Thanks Christian. I am aware of how to create string queries but what part of the form would i insert the query? Would it be the button that the user clicks when they have chosen what they want from the combo boxes? David

          T C 2 Replies Last reply
          0
          • S Shrimpersfan

            Thanks Christian. I am aware of how to create string queries but what part of the form would i insert the query? Would it be the button that the user clicks when they have chosen what they want from the combo boxes? David

            T Offline
            T Offline
            Tom Deketelaere
            wrote on last edited by
            #5

            Yes , when else would you do it? Well I guess you could also do it in the selectedindexchanged event off the comboboxes but that is making things more difficult then they need to be.

            1 Reply Last reply
            0
            • T Tom Deketelaere

              Christian Graus wrote:

              there's probably no harm in string mashing your SQL together.

              True but he can still use parameters for that extra security :) (its just a little bit more code)

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Oh, I'd normally agree, but in this case, I got the feeling that just string mashing SQL was going to confuse him.

              Christian Graus Driven to the arms of OSX by Vista.

              1 Reply Last reply
              0
              • S Shrimpersfan

                Thanks Christian. I am aware of how to create string queries but what part of the form would i insert the query? Would it be the button that the user clicks when they have chosen what they want from the combo boxes? David

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                Well, that's entirely up to you, when do you want the query to run ? A button is easiest, as someone else said.

                Christian Graus Driven to the arms of OSX by Vista.

                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