Creating query from multiple combo boxes
-
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.
-
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.
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.
-
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.
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)
-
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.
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
-
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
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.
-
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)
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.
-
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
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.